KB Article #152221

How to get SecureClient exit code

Problem

How can I get the exit code returned after invoking SecureClient script in batch mode?


Resolution


In order to get the exit code when running a SClient script, you need to do the following:



1. Create a .bat file (e.g., “opensite.bat”) in the SClient home folder. This .bat file should only call sclient script. Example syntax of the “opensite.bat” file follows:


sclient script "run.txt"


2. Create .bat file (e.g., “main.bat”) in the SClient home folder, from which you should call the “opensite.bat” file and get the exit code returned by it. You can use the following syntax of “main.bat” as an example:



@echo off
call opensite.bat
echo ---------------------------------------------
echo Exit Code = %ERRORLEVEL%
if %ERRORLEVEL% == 0 echo All commands ended without error
if %ERRORLEVEL% == 1 echo Connecting site is unknown
if %ERRORLEVEL% == 2 echo Invalid command
if %ERRORLEVEL% == 3 echo Syntax error or script execution error
if %ERRORLEVEL% == 4 echo Protocol error
if %ERRORLEVEL% == 100 echo License error
if %ERRORLEVEL% == 111 echo Scheduler failed to start within the Rescuer Timeout