sfunk1x Posted October 17, 2005 Posted October 17, 2005 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? :">
bluebearr Posted October 17, 2005 Posted October 17, 2005 (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 October 17, 2005 by bluebearr BlueBearrOddly enough, this is what I do for fun.
Skruge Posted October 17, 2005 Posted October 17, 2005 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]
sfunk1x Posted October 18, 2005 Author Posted October 18, 2005 (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 October 18, 2005 by sfunk1x
jonk Posted October 18, 2005 Posted October 18, 2005 If you don't know the GUID of an application use the msi-package instead. e.g. msiexec.exe /x pathAndNameOfTheMSIPackage.msi
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now