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.
Post Reply
User avatar
Bender2010
Posts: 6
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Thu Mar 22, 2018 8:03 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: 14445
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ExitCode in compiled GUI

Post by jvierra »

Should be:

$global:ExitCode = 88

Post Reply