Jump to content
Sign in to follow this  

Finding GUID for specific application in registry

Recommended Posts


Hey all -

I'm trying to write some uninstall code for an app, but unfortuantely I can't use Add/Remove programs, and I need to use MSIExec. The only way to do this, however, is to know the GUID of the app which is dynamically created. I know what values inside the key to look for (Displayname, would positively identify it) and the Keyname is actually the applications GUID, for example:


it would be nice if the key stayed the same, but alas, it doesn't.

Any ideas as to what I could do? I thought about exporting the Uninstall hive to text file and then searching the txt file for the Displayname portion, but how could I manage to tell it to search for the root of that (the GUID) without giving it specific line numbers (which woul dbe impossible given this has to run on several machines which the GUIDs will all be different).

Help? :">

Share this post

Link to post
Share on other sites

You can use RegEnumKey to step through the subkeys and find the one you want, as long as you have something you can test to the distinguish the correct subkey. Uninstall keys almost always have a DisplayName value, so that's a good thing to key off of. Here is sample code:

; Find the GUID for the Google Toolbar
$index = 1
$keyroot = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$subkey = "***START***"; we use this because "" will make our While loop exit
While $subkey <> ""
    $subkey = RegEnumKey($keyroot, $index)
    If StringInStr(RegRead($keyroot & "\" & $subkey, "DisplayName"), _
    "Google Toolbar for Internet Explorer") Then
        $GUID = $subkey  ; Record the GUID
        $subkey = ""    ; Force the While to exit
    $index = $index + 1

MsgBox(0, "Google Toolbar", "Google Toolbar GUID: " & $GUID)
Edited by bluebearr

BlueBearrOddly enough, this is what I do for fun.

Share this post

Link to post
Share on other sites

MSI data is also stored in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData

See where the data you need is, and follow bluebearr's example.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post

Link to post
Share on other sites

I'm curious, what purpose does the underscore before the "Google Toolbar"... serve?


Nevermind, had to remove that for it to compile properly.

Edited by sfunk1x

Share this post

Link to post
Share on other sites

If you don't know the GUID of an application use the msi-package instead.


msiexec.exe /x pathAndNameOfTheMSIPackage.msi

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this