Desktop and Mobile Device Management software
Software Installation - How To
Every command or script returns with the status of execution, which is referred as return status or exit codes. A successful command returns a 0 while an unsuccessful one returns a non-zero value that usually can be interpreted as an Error Code. The last command executed in the function or the script determines the exit status. This document provides steps on how to return the error codes on .vb scripts, Powershell scripts and batch files.
Exit codes for batch files
Use the command EXIT /B %ERRORLEVEL% at the end of the batch file to return the error codes from the batch file
Note: Environment variables are a set of dynamic named values that can affect the way, running processes will behave on a computer. For example, an environment variable with a standard name can store the location that a particular computer system uses to store user profile this may vary from one computer system to another.
In the batch file , it is always a good practice to use environment variables instead of constant values. Since the same variable get expanded to different values on different computers.
Batch file for Copying File to a Folder
Exit codes for powershell script
Use the command Exit $LASTEXITCODE at the end of the powershell script to return the error codes from the powershell script.
Powershell script for copying file to a folder
Exit codes for vb script
Use wscript.quit Err.Number at the end of the vb script which will return the last error codes from the script