Jump to content

Recommended Posts

Posted

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:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9EF149EC-2375-429A-910D-1EFA489B67F6}

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? :">

Posted (edited)

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
    EndIf
    $index = $index + 1
WEnd

MsgBox(0, "Google Toolbar", "Google Toolbar GUID: " & $GUID)
Edited by bluebearr
BlueBearrOddly enough, this is what I do for fun.
Posted

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]

Posted (edited)

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
Posted

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

e.g.

msiexec.exe /x pathAndNameOfTheMSIPackage.msi

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...