Computer Hope
Microsoft => Microsoft DOS => Topic started by: minnehaha on February 02, 2007, 01:00:36 PM
-
Hello,
I am trying to have this batch file check the presence of registry entries. I do not want it to print anything to the screen. If the value is present I want it to print to a text file.
reg query hkcu\software\sample
if errorlevel=0 echo "hkcu\software\sample">>list.txt
That is what I have so far.
Any advice would be greatly appreciated.
-
If all you want in your output file is "hkcu\software\sample" then you're all set and you don't even need the reg utility!
I suspect you want the result of the query in your output file:
reg query "hkcu\software\sample" >> list.txt
Hope this helps. 8-)
Not even sure the reg utility assigns errorlevels.
-
I do not want the results printed. errorlevel 0 means that it found the reg key and errorlevel 1 means the key is missing. It the key exists, I want the name of the key printed in the text file.
Right now what I listed gives me what I want but TOO MUCH - is there a way I can have the result of the query not printed to the screen or a file but still access the errorlevel? The results of the query are printed to the screen but that clutters the screen.
-
reg query hkcu\software\sample > nul
if errorlevel 0 echo "hkcu\software\sample">>list.txt
8-)
-
YES that works!!! I knew I was missing something small.
Thanks!!!!!!!!!