ExitCode in compiled GUI

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

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 3 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.
Locked
User avatar
Bender2010
Posts: 6
Last visit: Mon Jan 29, 2024 1:29 am

ExitCode in compiled GUI

Post by Bender2010 »

Hello together,

Product: PowerShell Studio 2020 5.7.179
Version: 64 Bit
OS: 64 Bit

I have created a simple GUI with only a Button to Exit. When click on the Button, the complied EXE file shoud be return a specific return code. When I understand correctly, I must using for that $script:ExitCode = XX.

I have added this to my function unter MainForm.psf

Code: Select all

$btn_Exit_Click={
	#TODO: Place custom script here	
	$script:ExitCode = 99
	$frm_Main.Close()
}
For a test, I have also added on the end this line to Startup.pss.

When I run in a cmd.exe my complied exe file, echo %errorlevel% returns everytime 0.

Is $script:ExitCode not working with compiled forms?

Best regards
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ExitCode in compiled GUI

Post by jvierra »

Should be:

$global:ExitCode = 88
This topic is 3 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.
Locked