rcmaehl Posted August 12, 2021 Share Posted August 12, 2021 (edited) Hi all, I'm attempting to get the exit state of an AutoIt script after using Exit 1 Exit 1 can literally be the only line in the script yet both $? and $LastExitCode are unable to detect that it exited with an error. I'm assuming this is because the script sets %ERRRORLEVEL% but I am unsure. I've also tried the below suggestion but it also seems to not work What am I doing wrong? Edited August 12, 2021 by rcmaehl My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
Musashi Posted August 12, 2021 Share Posted August 12, 2021 Compile e.g. (Scriptname = ReturnExitvalue.au3) Global $g_sValue $g_sValue = InputBox("Test", "Enter a number between 1 and 99 : ", "0") MsgBox(4096, "", "%ERRORLEVEL% = "& $g_sValue) Exit($g_sValue) Run via .cmd : @echo off echo starts Exe and displays the Returnvalue (Exit) cd %~dp0 ReturnExitvalue echo. echo %ERRORLEVEL% pause "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
rcmaehl Posted August 12, 2021 Author Share Posted August 12, 2021 5 minutes ago, Musashi said: Compile e.g. (Scriptname = ReturnExitvalue.au3) Global $g_sValue $g_sValue = InputBox("Test", "Enter a number between 1 and 99 : ", "0") MsgBox(4096, "", "%ERRORLEVEL% = "& $g_sValue) Exit($g_sValue) Run via .cmd : @echo off echo starts Exe and displays the Returnvalue (Exit) cd %~dp0 ReturnExitvalue echo. echo %ERRORLEVEL% pause Okay so there's no way to do this through powershell, has to be console? My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
Musashi Posted August 12, 2021 Share Posted August 12, 2021 2 minutes ago, rcmaehl said: Okay so there's no way to do this through powershell, has to be console? Not necessarily, but that's how I've always evaluated the return value so far. There has been no reason yet for me to do it otherwise . "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Solution Danyfirex Posted August 16, 2021 Solution Share Posted August 16, 2021 Hello. Do it like this. (Start-Process App.exe -PassThru -Wait).ExitCode Saludos Gianni and rcmaehl 2 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
rcmaehl Posted August 18, 2021 Author Share Posted August 18, 2021 On 8/16/2021 at 1:13 PM, Danyfirex said: Hello. Do it like this. (Start-Process App.exe -PassThru -Wait).ExitCode Saludos THANK YOU My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now