- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
Sep 22, 2008
11:54 AM
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.
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.
1 Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
Jan 29, 2009
10:42 AM
bobdux,
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. 😄
Brilliant!
Thanks
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. 😄
Brilliant!
Thanks
