Joe G
asked on
find and delete registry strings in keys batch file
I have a need to delete any strings in a certain registry key location that has the word redirect in it. Batch file is preferable but VB is welcomed.
example;
reg key location
hkcu\software\Microsoft\wi ndows NT\devices\
string value (any string with the below in the value)
redirect
example;
reg key location
hkcu\software\Microsoft\wi
string value (any string with the below in the value)
redirect
i use regseeker for that : http://www.hoverdesk.net/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
both of them worked. thank you!
not working for me the Find variable *s mean that it's wildcard before and after the term right? Anyway just getting an error even on running the exact string value:
C:\Scripts>reg query "HKCU\Software\Microsoft\W indows\Cur rentVersio n\Explorer \Shell Folders" /v "\\test\test" | find "REG_SZ"
ERROR: The system was unable to find the specified registry key or value.
C:\Scripts>reg query "HKCU\Software\Microsoft\W
ERROR: The system was unable to find the specified registry key or value.
Can you do the following at a command prompt and post the results. Based on what you described it does not seem that the KEY named "\\test\test" exists, which I would not expect it to. The key names are typically reserved works / names like "AppData", "Desktop", "Start Menu", etc.
Anyway, you can check this by the following:
reg query "HKCU\Software\Microsoft\W indows\Cur rentVersio n\Explorer \Shell Folders"
and see what keys are listed.
~bp
Anyway, you can check this by the following:
reg query "HKCU\Software\Microsoft\W
and see what keys are listed.
~bp
I was actually able to get it going with this syntax:
SET KEY=HKCU\Software\Microsof t\Windows\ CurrentVer sion\Explo rer\Shell Folders
SET VALUE=\\OLDSERVERNAME*
for /F "tokens=1,*" %%a in ('REG QUERY "%KEY%" ^| findstr /I "%VALUE%"') do (REG DELETE "%KEY%" /v %%a /f)
I had to specify the \\ in the UNC path it didn't like a preceding wildcard in the variable. BUT I would like to figure out how to get that preceding wildcard working for future situations (doesn't apply here because this string in this instance will always start with \\OLDSERVERNAME)
SET KEY=HKCU\Software\Microsof
SET VALUE=\\OLDSERVERNAME*
for /F "tokens=1,*" %%a in ('REG QUERY "%KEY%" ^| findstr /I "%VALUE%"') do (REG DELETE "%KEY%" /v %%a /f)
I had to specify the \\ in the UNC path it didn't like a preceding wildcard in the variable. BUT I would like to figure out how to get that preceding wildcard working for future situations (doesn't apply here because this string in this instance will always start with \\OLDSERVERNAME)
The leading asterisk definitely works, as in this test I just did:
C:\> reg.exe query "HKCU\Software\Microsoft\W indows NT\CurrentVersion\Devices" /v "*envy*"
HKEY_CURRENT_USER\Software \Microsoft \Windows NT\CurrentVersion\Devices
HP ENVY 120 series (Network) REG_SZ winspool,Ne01:
~bp
C:\> reg.exe query "HKCU\Software\Microsoft\W
HKEY_CURRENT_USER\Software
HP ENVY 120 series (Network) REG_SZ winspool,Ne01:
~bp