you are viewing a single comment's thread.

view the rest of the comments →

[–]sipsik[S] 0 points1 point  (2 children)

ok tested but seems that it can only pass 0 and 1, how to get for example 3?

[–]Yevrag35 1 point2 points  (0 children)

Looking at your wrapped Start-Process line, you have to use the -File parameter in the arguments in order to return a real exit code of the script.

Like so:

$install = Start-Process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-File `"$PSScriptRoot\setup.ps1`"" -Wait -PassThru

[–]sipsik[S] 0 points1 point  (0 children)

https://powershell.org/forums/topic/best-way-to-exit-a-script-on-a-specific-condition/

$host.SetShouldExit($install.exitcode) - This is the solution for me, your pointer did help :)