Script to test the exit code by an application
At several instances, I came across issues where an application gets installed / uninstalled successfully, however the reports show that the application has failed. This particularly happens when the exit code returned by the application is not 0. If you are using SCCM 2007, or any other deployment tools or application, a success is represented by exit code = 0, but if the application is built to return 1 as success, the reports will show that the application has failed which is not true. Exit code 1 is interpreted as failure by SCCM. Now how do you verify the exit code returned by the application when you do not have any logs to produce that? Here’s what you do: You can use the following script to see the exit code that an application returns.
The following script will let you know what is the exit code
Run the script which in turn will fire the application and wait for the application to get installed / uninstalled successfully, it will then return the exit code
Script as follow:
Option Explicit
Dim oWSHShell 'As WScript.Shell
Dim oExec 'As WshScriptExec
Set oWSHShell = CreateObject("WScript.Shell")
Set oExec = oWSHShell.Exec("setup.exe")
Do While oExec.Status = 0
Call WScript.Sleep(100)
Loop
If oExec.ExitCode < 0 And oExec.ExitCode > 1 Then
Call WScript.Quit(oExec.ExitCode)
End If
'Uncomment the following to see the exit code
Call WScript.Echo(oExec.ExitCode)
Set oExec = Nothing
Set oWSHShell = Nothing
Replace Setup.exe with the path and file name of the application
e.g. C:\Setup.exe where path = C:\ and executable file = setup.exe