I'm writing a small batch file in windows that needs to run a nodejs app. Before running the app I need to make sure that node is installed by the user, and if not show him a message that node is required.
What I did is this:
@echo OFF
setlocal EnableDelayedExpansion
REM Check if node is installed
for /f "delims=" %%i in ('node -v') do set output=%%i
IF "!output!" EQU "" (
echo node could not be found
) else (
node %~dp0app.js
)
If the user has node installed then output
will contain the version number. If not installed then it will be empty. This logic works. But if node is not installed (node -v
command not found), the batch result also shows the following output:
'node' is not recognized as an internal or external command,
operable program or batch file.
node could not be found
I would like to hide the "not recognized" message from the user and just show "node could not be found".
How can I hide it?