.Bat / CMD - 如果找不到密钥,则隐藏“ERROR”

时间:2017-09-29 22:26:16

标签: batch-file cmd registry echo

这是我的代码:

@echo off

echo Checking 32bit registry.
REG QUERY "HKLM\Software\EA GAMES\NFSMW" /v InstallDir >nul
If %ERRORLEVEL% == 0 goto CHECKEND
If %ERRORLEVEL% == 1 goto CHECK64

:CHECK64
echo Checking 64bit registry.
REG QUERY "HKLM\Software\Wow6432Node\EA GAMES\NFSMW" /v InstallDir >nul
If %ERRORLEVEL% == 0 goto CHECKEND
If %ERRORLEVEL% == 1 goto CLOSE

:CHECKEND
echo Registry key was found. Preparing uninstall...

:CLOSE
pause
exit

我的问题是:如何隐藏错误:系统无法找到指定的注册表项或值。如果找不到密钥?

问候。

1 个答案:

答案 0 :(得分:2)

REG QUERY "HKLM\Software\EA GAMES\NFSMW" /v InstallDir >nul 2>&1

REG QUERY "HKLM\Software\Wow6432Node\EA GAMES\NFSMW" /v InstallDir >nul 2>&1

正在隐藏该输出。