not getting output from msgbox

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
Olga_B
Site Admin
Posts: 196
Last visit: Thu Mar 28, 2024 8:34 am

Re: not getting output from msgbox

Post by Olga_B »

The 'Microsoft.PowerShell.Core' in Get-Location is expected PowerShell behavior

Check this:

https://community.idera.com/database-to ... hell-paths

Also, If you can, please zip and load up the original psf file, so that we can attempt to recreate the issue using your file:

https://www.sapien.com/support/upload
User avatar
ocsscott6969
Posts: 48
Last visit: Tue Dec 05, 2023 10:04 am

Re: not getting output from msgbox

Post by ocsscott6969 »

im about to upload uncomment line 53-65 to see the behavior the first sections for $a and $b

the code for $C is working but previously the $a code was what you suggested I use.

thanks
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 1:00 pm
Answers: 39
Been upvoted: 30 times

Re: not getting output from msgbox

Post by brittneyr »

We have been able to reproduce the problem you are having with getting values from PSScriptRoot and PSCommmandPath not returning anything when packaged. The issue has been sent to the proper place for evaluation and correction. When a fix is issued with a service build, it will be listed in the change log.

We apologize for any inconvenience.
Brittney
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: not getting output from msgbox

Post by Alexander Riedel »

$PSScriptRoot and $PSCommandPath are filled where possible as a convenience to users. You must keep in mind though that packaged code does not run as a script.
It is executed as code in a custom host. So there are some differences to keep in mind and PowerShell is likely getting confused as to the scope of these variables.
Which is why they show up empty rather than producing an error.

Please refer to: https://www.sapien.com/blog/2009/09/02/ ... nvocation/

The proper way to reliably determine the path of a script and likewise that of the underlying executable executable in a script package is as follows:

function get-scriptdirectory{
if($hostinvocation -ne $null) {
Split-Path $hostinvocation.MyCommand.path
}
else {
$invocation=(get-variable MyInvocation -Scope 1).Value
Split-Path $invocation.myinvocation.path
}
}

Calling this function will return the correct path whether the code is run as a script file or if it is packaged as an executable file.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
ocsscott6969
Posts: 48
Last visit: Tue Dec 05, 2023 10:04 am

Re: not getting output from msgbox

Post by ocsscott6969 »

Thanks for the code and explanation of the issue
This topic is 4 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.