Computing.Net > Forums > Programming > Reg query

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.

Reg query

Reply to Message Icon

Name: jestes1013
Date: August 7, 2009 at 11:32:26 Pacific
OS: Windows XP
Product: Dell / OPTIPLEX GX620
Subcategory: Batch
Tags: batch, REG, Query, DELETE
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
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

Related Posts

See More



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.

Thanks again.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Reg query

Change reg query output www.computing.net/answers/programming/change-reg-query-output/17105.html

completely disable output of reg query www.computing.net/answers/programming/completely-disable-output-of-reg-query/19201.html

Eval reg entry w/carriage returns www.computing.net/answers/programming/eval-reg-entry-wcarriage-returns/15573.html