2👍
✅
There are no try-catch
blocks in batch scripts. You need to use the errorlevel
returned by a command to check whether it executed successfully or failed. Generally errorlevel 0
indicates that the command executed successfully, but the errorlevel can also depend on the command/program being executed.
Details about ERRORLEVEL.
ERRORLEVEL can be used as follows:
IF %ERRORLEVEL% NEQ 0 (do something)
Source:stackexchange.com