CyberSlug Posted January 4, 2004 Share Posted January 4, 2004 (edited) EDIT: The problem is that %errorlevel% gets set back to zero before I read it...RunWait("C:\SomeCompiledScript.exe")MsgBox(0,"", EnvGet("errorlevel"))Exit====How do you read a program's return value / exit code / errorlevel in AutoIt?I can only figure out how to do it with a batch file:REM Sample Batch file @echo off "C:\SomeCompiledScript.exe" echo Return value was %errorlevel% pauseThanks Edited January 4, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted January 4, 2004 Share Posted January 4, 2004 EDIT: The problem is that %errorlevel% gets set back to zero before I read it... RunWait("C:\SomeCompiledScript.exe") MsgBox(0,"", EnvGet("errorlevel")) Exit ==== How do you read a program's return value / exit code / errorlevel in AutoIt? I can only figure out how to do it with a batch file:REM Sample Batch file @echo off "C:\SomeCompiledScript.exe" echo Return value was %errorlevel% pause ThanksDoes Run/RunWait return the exit code from the program? I've never tried, but it may. Link to comment Share on other sites More sharing options...
Valik Posted January 4, 2004 Share Posted January 4, 2004 No, it appears not. Perhaps Run/RunWait should be modified to return the exit code from whatever program they launch. Link to comment Share on other sites More sharing options...
CyberSlug Posted January 4, 2004 Author Share Posted January 4, 2004 (edited) I'm an idiot. Valik put me on the right track.$var = RunWait("C:\SomeProgram.exe")MsgBox(0, "Return value is", $var)Note: You must use RunWait instead of Run, but that's not a bug (it really is a feature):iamstupid: Edited January 4, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
GEOSoft Posted January 4, 2004 Share Posted January 4, 2004 I was going to suggest RunWait("C:\SomeCompiledScript.exe") $Var = @error MsgBox(0,"", $Var) Exit I just tested it and it returns 0 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Valik Posted January 4, 2004 Share Posted January 4, 2004 :iamstupid: I looked at the source code last night to see if it was setting the return value, but I only looked at the code for Run. It was late and it never ocurred to me that Run wouldn't have a return code because of how it works. I didn't even look at RunWait. So, I read your post, I open the source again to have a look, and the cursor is almost on the line that assigns the programs return value to RunWait's return value. :iamstupid: 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