hello,
I am really stuck on this task and not been able to get my script to work.
Here is what I want to do:
1. Search "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Print\Printers" location (include all sub keys) for a value called "Test"
2. If the value exists, delete the test value.
So far have been able to do a simple reg query:
REG QUERY "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Print\Printers" /v Test /s
My results are as follows: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Print\Printers\PRINTER1\DsDriver
test REG_BINARY
End of search: 1 match(es) found.
How would I delete this value now? The problem I face is that this "test" value could be under any key.
Any help would be much appreciated
reg query help
Moderator: DosItHelp
Re: reg query help
SeanT wrote: How would I delete this value now? The problem I face is that this "test" value could be under any key.
Do you mean any key under this one?
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Print\Printers
Re: reg query help
Try something like that:
That example only displays the command lines. If you see you found the right keys remove ECHO (and perhaps PAUSE as well) to execute the REG DELETE command line.
Regards
aGerman
Code: Select all
@echo off &setlocal
set "regpath=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Print\Printers"
set "value=test"
for /f "delims=" %%i in (
'reg query "%regpath%" /v "%value%" /s ^| findstr /bic:"%regpath%"'
) do (
ECHO reg delete "%%i" /v "%value%" /f
)
PAUSE
That example only displays the command lines. If you see you found the right keys remove ECHO (and perhaps PAUSE as well) to execute the REG DELETE command line.
Regards
aGerman
Re: reg query help
aGerman,
That works perfectly. I spend so many hours to get this to work....your help is much appreciated.
Vielen Dank!!!
Sean
That works perfectly. I spend so many hours to get this to work....your help is much appreciated.
Vielen Dank!!!
Sean
-
- Posts: 3
- Joined: 23 Sep 2013 09:03
Re: reg query help
Hi, guys!
I'm from Brazil, I like batch script.
Very Good.
I'm from Brazil, I like batch script.
Very Good.