StrongWind
StrongWind

Reputation: 45

How to get rid of error message in reg query in bat file?

Here is the question. I got this script. The registry value doesn't exist. Obviously I will get an error

ERROR: The system was unable to find the specified registry key or value.

But I don't want users to see this. Because I will do something about it. I tried to use redirect it to nul it doesn't work.

hope someone can help. Thanks.

@ECHO OFF REG QUERY HKLM\SOFTWARE\MyApplication\Resources /v %REGVAL_INSTALLDIR% >nul ||( GOTO NOTFOUND ) :NOTFOUND REM I'll DO SOMETHING ELSE exit /b

Upvotes: 0

Views: 4394

Answers (1)

npocmaka
npocmaka

Reputation: 57282

@ECHO OFF
REG QUERY HKLM\SOFTWARE\MyApplication\Resources /v %REGVAL_INSTALLDIR% >nul 2>nul ||( GOTO NOTFOUND )
:NOTFOUND
   REM I'll DO SOMETHING ELSE
exit /b

error messages are printed in 2 stream so you need to redirect it also to nul

Upvotes: 2

Related Questions