Tips: How to Effortlessly Check Errorlevel


Tips: How to Effortlessly Check Errorlevel

ErrorLevel is a special variable in batch files that stores the exit code of the last command executed. It can be used to check if a command was successful or not. To check the ErrorLevel, you can use the IF command. For example, the following code checks if the previous command was successful (ErrorLevel is 0) and, if so, it displays a success message:

if errorlevel 0 (  echo Command was successful)  

The ErrorLevel variable can be used to handle errors in batch files and to make your scripts more robust.

Read more

close