Capture error message from REG??

Microsoft Windows xp pro with sp3 multil...
January 28, 2010 at 11:43:25
Specs: Windows XP
Is there a way to capture the actual error message the REG.exe puts out?

Here's what I've got.

Reg query \\%compname%\HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0 | find "x86 Family" /I
IF %ERRORLEVEL%==0 echo %compname% is running a 32bit Operating System >>%outfile%
IF %ERRORLEVEL%==1 echo %compname% is running a 64bit Operating System >>%outfile%

I am trying to determine the OS type based on reg key. It works fine until I hit an instance where the key does not exist, ie the machine can not be reached.

I always get ERRORLEVEL=1. and REG sends this message to the screen "Error: The network path was not found."

Any thoughts?

See More: Capture error message from REG??

Report •

January 28, 2010 at 16:35:59
you could capture it into a file, but then you got to open and read and analyze the file. this will capture to file:
Reg query \\%compname%\HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0 2>testfil | find "x86 Family" /I

the other option is to ping the host before doing the regquery:
for /f "tokens=* delims=" %%a in ('ping -n 1%compname% | find "Lost = 0"') do (
set xx=%%a
set test=%errorlevel%

then analyze either %test% or %xx% to see if connected.
of course, ping will add some seconds to the run-time.

Report •
Related Solutions

Ask Question