1
If I run the following:
@ECHO OFF
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\SOFTWARE\SomeApp\Server" /v ServerName') DO SET ServerName=%%B
ECHO Server: %ServerName%
and the registry doesn't exist, it gives the following error
ERROR: The system was unable to find the specified registry key or value.
I know the error is expected, but how can suppress this error?
Not too concerned about the ECHO part showing just "SERVER:" with no value, that's fine to me.
This answer is wrong. You need to escape redirect operator as mentioned in the other answer – Abhijit – 2016-05-26T09:22:27.040