The command line program will return an ERRORLEVEL to the operating system which can be analyzed by a calling program to determine what happened. The following table describes the errors.
| Code | Description | Returned as Script Status in output file |
|---|---|---|
| 0 | No errors. All scripts were executed successfully. | Yes |
| 1 | Fatal error. The command line program could not execute at all. One reason could be that a language resource file is missing | No |
| 2 | Failed to create the Silk Test COM object. Check that the COM object has been registered. Note that running Silk Test.exe registers the COM object. | No |
| 3 | DSN, username, or password incorrect. For additional information, see Prerequisites to Run STW.EXE with Silk Central. | No |
| 4 | No script name was specified. | No |
| 5 | The specified project was not found. | No |
| 6 | The specified script was not found. | No |
| 7 | The specified run environment was not found. | No |
| 8 | Invalid script parameters. Too few or too many script parameters were specified, or a parameter was not found. | No |
| 9 | The script did not complete execution. It may have stopped before it reached the end but not a result of a playback error. | Yes |
| 10 | The script failed with playback errors. | Yes |
| 11 | The script failed to execute or the script contained verifications that failed. | Yes |
| 12 | Multiple issues have occurred. For example, a script failed and a script playback error was detected. | No |
| 13 | This is returned if the command line could not be processed due to the -file option. For example, if the file does not exist, or there is file recursion. | No |
| 14 | There are various different ways that the command line window can be stopped or shut down. Ctrl+C, Ctrl+Break, logging out of Windows, or shutting down Windows will all close or stop the command line. These will be caught and this error code will be returned. Closing the window will also stop the script, log out of the product, and unload SilkTest.EXE. | No |
There are a number of ways to check for the ERRORLEVEL in a batch file. The following example describes one approach.
@ECHO OFF
SETLOCAL
REM ----------------------------------------------------------------------------
REM Define the error codes that can be returned by STW.EXE
REM ----------------------------------------------------------------------------
SET eNoError=0
SET eFatalError=2
SET eUnableToCreateComObject=2
SET eLoginFailed=3
SET eNoScriptSpecified=4
SET eProjectNotFound=5
SET eScriptNotFound=6
SET eRunEnvNotFound=7
SET eInvalidScriptParameters=8
SET eScriptDidNotComplete=9
SET eScriptPlaybackError=10
SET eScriptFailed=11
SET eMultipleProblems=12
REM ----------------------------------------------------------------------------
REM Run STW.EXE
REM ----------------------------------------------------------------------------
@ECHO ON
STW.EXE -username Admin -dsn STW-Scratch -script ScriptNotFound
@ECHO.
@ECHO OFF
REM ----------------------------------------------------------------------------
REM Anything greater than 12 is unknown, can be caused if the command
REM processor cannot find STW.EXE.
REM ----------------------------------------------------------------------------
IF %ERRORLEVEL% GTR %eMultipleProblems% (
ECHO STW.EXE returned an unknown return code %ERRORLEVEL%
GOTO END
)
REM ----------------------------------------------------------------------------
REM Check the specific error codes here.
REM ----------------------------------------------------------------------------
IF %ERRORLEVEL% EQU %eMultipleProblems% (
ECHO eMultipleProblems
GOTO END
)
IF %ERRORLEVEL% EQU %eScriptFailed% (
ECHO eScriptFailed
GOTO END
)
IF %ERRORLEVEL% EQU %eScriptPlaybackError% (
ECHO eScriptPlaybackError
GOTO END
)
IF %ERRORLEVEL% EQU %eScriptDidNotComplete% (
ECHO eScriptDidNotComplete
GOTO END
)
IF %ERRORLEVEL% EQU %eInvalidScriptParameters% (
ECHO eInvalidScriptParameters
GOTO END
)
IF %ERRORLEVEL% EQU %eRunEnvNotFound% (
ECHO eRunEnvNotFound
GOTO END
)
IF %ERRORLEVEL% EQU %eScriptNotFound% (
ECHO eScriptNotFound
GOTO END
)
IF %ERRORLEVEL% EQU %eProjectNotFound% (
ECHO eProjectNotFound
GOTO END
)
IF %ERRORLEVEL% EQU %eNoScriptSpecified% (
ECHO eNoScriptSpecified
GOTO END
)
IF %ERRORLEVEL% EQU %eLoginFailed% (
ECHO eLoginFailed
GOTO END
)
IF %ERRORLEVEL% EQU %eUnableToCreateComObject% (
ECHO eUnableToCreateComObject
GOTO END
)
IF %ERRORLEVEL% EQU %eFatalError% (
ECHO eFatalError
GOTO END
)
IF %ERRORLEVEL% EQU %eNoError% (
ECHO eNoError
GOTO END
)
:END
ENDLOCAL