ERRORLEVEL and Where.exe program
Posted: 08 Jan 2021 04:58
I'd like to have a readable form of code that checks whether a program is available to be used.
It's mostly to check if the program is available from the PATH Environment Variable.
I'd like to ask if this makes any sense and is a correct way to do that, or you have any improvements on that.
NOTES:
/Q argument can be added to silent the output of Where.exe program.
Also the alternative:
Update
The same above maybe can be rewritten as this:
A shorter version indeed, but maybe not much of a pleasure to read.
It's mostly to check if the program is available from the PATH Environment Variable.
I'd like to ask if this makes any sense and is a correct way to do that, or you have any improvements on that.
Code: Select all
@ECHO OFF
WHERE cmd.exe
IF ERRORLEVEL 01 ECHO the program is not found.
PAUSE
/Q argument can be added to silent the output of Where.exe program.
Code: Select all
WHERE /Q cmd.exe
Code: Select all
WHERE cmd.exe >NUL 2>NUL
The same above maybe can be rewritten as this:
Code: Select all
@ECHO OFF
WHERE cmd.exe || ECHO the program is not found.
PAUSE