hackndoes Posted July 6, 2010 Posted July 6, 2010 I run a script in which I set the exit code to the return value of a function that returns either 0 or 1 the script is : Exit(WinClose("title")); the %errorlevel% is not set to the Exit code I supplied to Exit method (even when doing in the script only Exit 22) how can that be? P.S also tried compiling the script first and the behavior is the same. I am using windows xp sp2 autoit version 3.3.6.1 thanks.
whim Posted July 6, 2010 Posted July 6, 2010 Try replacing Exit(WinClose("title")) with Local $iVar = WinClose("title") Exit($iVar) HTH, whim
hackndoes Posted July 6, 2010 Author Posted July 6, 2010 already tried of course, same result. what I did notice is that if I put the two lines in a batch file like this: autoScript.au3 (that does Exit(22) echo %errorlevel% this does work and give the 22 as expected. how come? I need not to use the bat file since I am aiming at running the single command as /AutoIt3ExecuteLine to which I want to set the exit code. P.S also tried running: autoScript.au3 && echo %errorlevel% thinking it might run each line in a different cmd and this way I will prevent this behaviour but it also didn't help
hackndoes Posted July 6, 2010 Author Posted July 6, 2010 OK, I found a way to work around it (some might call it a solution) but I don't understand the behaviour. can someone please explain what the hell happens here and why? if I run the script like that: autoScript.au3 (that does 'Exit(22)') and then echo %errorlevel% NADA, error level is not set to 22 BUT if I do that: anotherCommand|autoScript.au3 and then echo %errorlevel% voila, I get 22 (hence errorlevel was set correctly.
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