Task Server fails to record the return code created by a command script job
search cancel

Task Server fails to record the return code created by a command script job

book

Article ID: 176783

calendar_today

Updated On:

Products

IT Management Suite Task Server

Issue/Introduction

The following syntax was used for a command script job:

:Start
if exist "c:\Program Files\Altiris\Software Virtualization Agent" goto installed
if not exist "c:\Program Files\Altiris\Software Virtualization Agent" goto notinstalled
goto end

:installed
echo installed
set errorlevel=0
goto end

:notinstalled
echo notinstalled
set errorlevel=1
goto end

:end
echo %errorlevel%
if exist "c:\Program Files\Altiris\Software Virtualization Agent" goto installed
if not exist "c:\Program Files\Altiris\Software Virtualization Agent" goto notinstalled
goto end

:installed
echo installed
set errorlevel=0
goto end

:notinstalled
echo notinstalled
set errorlevel=1
goto end

:end
echo %errorlevel%

Once this job had been run by the Client Task Agent, the Task Server displayed a return code of 0 with a status of success, even though the script return a code of 1.

Cause

By default, Task Server only records the action of running the script, and not what actions the script actually performs.

Resolution

In order for a command script to send back its return code to Task Server, the EXIT parameter must be used. All of the “set errorlevel=0 or 1” lines should be replaced with “Exit /B 0 or 1” which allows Task Server to function as expected by the user.


Applies To
Task Server 6.0, 6.0 SP1

Attachments