Jump to content
Sign in to follow this  
hackndoes

can't set the exit code for the process

Recommended Posts

hackndoes

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.

Share this post


Link to post
Share on other sites
hackndoes

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):blink:

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

Share this post


Link to post
Share on other sites
hackndoes

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×