Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 4

Windows bat scripts and EXECUTE_EXITCODE

Thought I would pass on this bit of information for anyone using the "Execute Script/Bat fFile" action with Windows.

If you exit your bat script with this:
exit /b 1

The EXECUTE_EXITCODE will be set to 0.

If you really want to capture the exitcode, you need to use:
exit 1

Why is this important? I was testing my bat script with "exit /b 1" until I was satisfied with my unit testing. I then pasted my script into the action, but my installer unit testing showed the EXECUTE_EXITCODE was _always_ set to 0. It took me a few iterations to figure out why,. For some reason the /b argument doesn't do what I expected in IA.

Hope this is helpful information for you.
Labels (1)
0 Kudos
(1) Reply
Level 2


Should you ever find yourself in the UK, I owe you at least a dozen pints! I have been going mad for a day as to why the return was always zero when my code seemed correct. I was messing with cscript, testing in VS, other shells, and everything worked there.

Then I discovered this post searching for 'execute' since using 'execute_stdexitcode' returned nothing(?) and within ten minutes a received the expected -1 that I had assigned to the variable in my JS. 😄

0 Kudos