PSS 2014 How to return an exit code from Windows Package

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 9 years and 9 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
mkedaj
Posts: 6
Last visit: Fri Jan 21, 2022 10:33 am

PSS 2014 How to return an exit code from Windows Package

Post by mkedaj »

Hi,

I want to package a script as Windows exe.
My sample code:
PowerShell Code
Double-click the code block to select all.
$script:ExitCode = 2
$global:ExitCode = 3
Packaged with "V3 Host (Command line) x64" :
PowerShell Code
Double-click the code block to select all.
PS C:\Test> .\TestExit.exe;$?;$LASTEXITCODE
False
3
Packaged with "V3 Host (Windows) x64" :
PowerShell Code
Double-click the code block to select all.
PS C:\Test> .\TestExit.exe;$?;$LASTEXITCODE
True
Is there a way to let the Windows version return an exit code?

Comment on the result of the command line version for those who are interested in:
If only $script:ExitCode is defined this value is the return code of the package.
If also $global:ExitCode is defined the global value is the return code of the package.
If the value of $ExitCode isn't numeric (e.g. "y" or $null) then $? is True and $LASTEXITCODE is 0.
Numeric strings ($ExitCode = "123") will work like numeric values.

Martin
This topic is 9 years and 9 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.