Return an error code for SCCM

Started by NickL, July 15, 2014, 01:52:37 AM

Previous topic - Next topic

NickL

Hi

We push WinBatch scripts out via Microsoft System Centre (SCCM).  What we have found is that the error reporting is misleading as SCCM will report that a program was deployed successfully.  However if the WinBatch script came across a problem and closed (via error trapping) it would still show as successful.

Is there any way of being able to programmatically return an error code so that SCCM would know that the process was unsuccessful?

Many thanks for any help/advice you can give

Deana

IntControl 1000 sets the exit code returned by WinBatch.

Code (winbatch) Select

exitcode = 0
IntControl(1000,exitcode,0,0,0) ; set exit code to zero for success

; upon error redefine exit code and exit
ErrorMode(@off)
badline
ErrorMode(@cancel)
exitcode = LastError()
If exitcode != 0
    IntControl(1000,exitcode,0,0,0)
   Exit
Endif

Exit



Deana F.
Technical Support
Wilson WindowWare Inc.

td

Assuming that SCCM is reading an exit code to determine the existence of an error state, use IntControl 1000 in your error handler to have your compiled script's exe return a numeric value that SCCM will recognize as indicating an error.

BTW, in order to push WinBatch scripts to multiple computers the scripts must either be compiled or you must have a multi-user license.  Otherwise, you are in violation of your licensing agreement. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade