Disclaimer

Sunday 16 September 2012

Scripts and exit codes

Colleague of mine asked me to write a small blurb on using exit codes when using scripts to wrap packages for deployment. This is a very simplistic overview. This is from an SMS/SCCM perspective, though this probably applies to other deployment tools (maybe).

Typically if you are just using some sort of script execute say an msi it might be in the following format:

On Error Resume Next
objFSO.dosomestuff
wshShell.Run "SomeApplication.msi" /qb /norestart
wScript.quit

This for the most part is fine, as long as you do not run into any problems with the deployment. The above will effectively always exit with a success code, so when you are looking through the deployment reports from SCCM even if  the application failed to install on all of the machines you are going to get 100% success rate as the script it self completed successfully.

A very basic way around this would be to have something like this:

If err.number <> 0 Then
      wScript.quit 1
   Else
      wScript.quit 0
End If

Where 1 is a generic error code and 0 is a generic success code. So if there is an issue with the execution of that msi then you will at least get an idea that there is a problem.

SCCM has a few exit codes that you could use in order to manipulate the advertisement behaviour:

Success:
Reboot:
1604
1641
3010
3011 
Retry*:
4
5
8
13
14
39
51
53
54
55
59
64
65
67
70
71
85
86
87
112
128
170
267
999
1003
1203
1219
1220
1222
1231
1232
1238
1265
1311
1323
1326
1330
1618
1622
2250
*) A retry exit code will force SMS/SCCM to rerun the advertisement after a timeout of 10 minutes.
 
The above exit codes are from here:

No comments:

Post a Comment