Page 2 of 2

Re: not getting output from msgbox

Posted: Tue Jul 16, 2019 10:09 am
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

Re: not getting output from msgbox

Posted: Tue Jul 16, 2019 10:43 am
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

Re: not getting output from msgbox

Posted: Tue Jul 16, 2019 11:40 am
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.

Re: not getting output from msgbox

Posted: Tue Jul 16, 2019 4:12 pm
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.

Re: not getting output from msgbox

Posted: Wed Jul 17, 2019 8:06 am
by ocsscott6969
Thanks for the code and explanation of the issue