SD Job returns the exit code of the script defined in the SD procedure. If the script called a second script, it will not report the exit code of the second script. How to report this ?
Example :
Package TEST_VBS 1.0 contains 2 files : install.bat and test.vbs
The install procedure executes install.bat
install.bat contains these lines :
cscript.exe test.vbs
echo test.vbs executed
test.vbs contains these lines :
Wscript.Echo "Hello"
WScript.Quit 123
When the package is sent to a machine, the SD Job is always is status OK because exit code is exit code of last line of install.bat script (which is echo command).
How to return the exit code (123) of vbs script in this example ?
Client Automation - All Versions
Add these 3 lines just after call of the second script :
SET RC=%ERRORLEVEL%
echo [RESULT] > "%SDROOT%\ASM\CONF\ASMINSTW.RES"
echo ErrorCode=%RC% >> "%SDROOT%\ASM\CONF\ASMINSTW.RES"
File %SDROOT%\ASM\CONF\ASMINSTW.RES is used by SD Agent to report the exit code of the job.
Example :
After adding the 3 lines in install.bat :
SD Job reports the exit code of test.vbs script
This solution could be applied for vbs script but for other kind of script too like .cmd, .bat, .ps etc...