Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
I have a batch file I am trying to create in regards to registry keys. I have a registry that changes its key name but always has the same Value Name and Value Data. For example; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BD68F46D-8A82-4664-8E68-F87C55BDEFD4} It is always in the uninstall section however the numbers in the {...} change. The REG_SZ value name is called DisplayName and I am looking for a specific Value Data for that name. Once I find the Value Data I am looking for I want to delete that key. Any Ideas
Name: Judago Date: August 7, 2009 at 17:57:31 Pacific
Reply:
This may get you some of the way:
@ECHO OFF
for /f "skip=2 delims=" %%a in ('
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
') do (
for /f "skip=4 tokens=2,* delims= " %%b in ('
2^>nul reg query "%%a" /v "displayname"
') do (
if not errorlevel 1 (
echo %%a contains the value: %%c
)
)
)
pause
0
Response Number 2
Name: jestes1013 Date: August 10, 2009 at 06:03:41 Pacific
Reply:
Ok so that works perfectly for getting the value (%%c). Now if I want to delete the key that has the value (%%c) I am looking for do I have to do another For /f loop? Sorry this is a little more advanced for batch than I have done before. I really appreciate your help. Thank you Judago!
0
Response Number 3
Name: jestes1013 Date: August 10, 2009 at 13:27:24 Pacific
Reply:
This works great!
@ECHO OFF for /f "skip=2 delims=" %%a in (' reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" ') do ( for /f "skip=4 tokens=2,* delims= " %%b in (' 2^>nul reg query "%%a" /v "displayname" ') do ( if "%%c"=="Displaynametodelete" ( reg delete %%a /f ) ) ) pause
0
Response Number 4
Name: Judago Date: August 11, 2009 at 01:12:38 Pacific
Reply:
Glad it helped, one thing though I would enclose %%a in double quotes in case the reg key contains a space.
0
Response Number 5
Name: jestes1013 Date: August 11, 2009 at 05:36:12 Pacific
Reply:
Good point. I really appreciate your help on this. Thank you very much.
0
Response Number 6
Name: jestes1013 Date: August 11, 2009 at 05:43:52 Pacific
Reply:
In this batch where would you could you echo and errorlevel msg?
0
Response Number 7
Name: Judago Date: August 11, 2009 at 05:56:19 Pacific
Reply:
In this batch where would you could you echo and errorlevel msg?
I'm not exactly sure what you are trying to get at....
It is a batch(for xp or higher) and you can use errorlevels and echo with it......
0
Response Number 8
Name: jestes1013 Date: August 11, 2009 at 10:52:33 Pacific
Reply:
Yeah that didn't come out the way I wanted to ask it. I figured it out though.
Summary: Hi What I want to do is change AltDefaultUserName to DefaultUserName in the output going to the DefaultUserName.reg @echo off cls for /f "tokens=* delims= " %%a in ('reg query "HKLM\SOFTWARE\Microsoft...
Summary: For example, when using: reg query "HKEY_CURRENT_USER\Software\Product" /v "InstallPath" it will output all values of that string. If we put >nul at the end, there will be no output, but only if that ...
Summary: Here's how I'm doing it so far. I am sure it can be simplified. I am a beginner so if there any suggestions to neated up this redundant code, they will be much appreciated. I'm only searching for pa...