/build/static/layout/Breadcrumb_cap_w.png

how to remove hkcu keys using MSI after uninstallation of a product?,

I faced one issue that my application is having one active setup registry which runs after installation and logoff/login. when i tried to uninstall and resinstall the same product, the active setup is not executed as its available already. Any solution is there to remove active setup hcku registry key during uninstall of the product.?

0 Comments   [ + ] Show comments

Answers (4)

Posted by: piyushnasa 12 years ago
Red Belt
1

You should write a vbscript to delete the HKCU keys and place it somewhere in Allusersprofile. Then you need to write a custom action to add a active setup key at uninstall and this active setup key should run the delete reg script placed earlier.

Posted by: olditguy 12 years ago
Second Degree Blue Belt
0

Active setup uses HKLM\software\microsoft\Active Setup\Installed Components\Name_or_id to uniqually identify the instance. If you use the MSI's GUID as the name_or_id part it will be globally unique. When a user logs in the HKLM part is compared with the value in HKCU and if it doesn't exist Active Setup runs whatever is in StubPath and then sets the HKCU key so it doesn't happen again.

If you uninstall the msi that wrote the HKLM part of the active setup then it won't run for any users after the uninstall as the HKLM part won't exist. If you re-install that same msi but increment the version value in the active setup key then it will run again for each user. The format for the version key is Version = a,b,c,d. Usually you start with version set to 1,0,0,0, then you can use 1,0,0,1 or 2,0,0,0 depending on how you want to do it. So long as you increment it on each version of your msi then it will always run for each user.

Posted by: akki 12 years ago
4th Degree Black Belt
0
In you package along with Stubpath add another string value "Version", and assign it value 1.
Refer this link to understand more :
http://www.sepago.de/helge/2010/04/22/active-setup-explained/

Also it is very important to add a custom action that runs during uninstall. This custom action should increment the value of "Version". For your reference use this script:
VBScript Code:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Option Explicit

On Error Resume Next

Dim objShell,intVersion

Set objShell = CreateObject("WScript.Shell")



intVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{ProductCode}\Version")

intVersion = intVersion + 1

objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{ProductCode}\Version", intVersion , "REG_SZ"



Set objShell = Nothing

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Posted by: Arminius 12 years ago
Second Degree Green Belt
0

HKCU and ActiveSetup is an interesting challenge.  Keep in mind that these keys exist for everyone who has logged in since the application was installed.  There are really 2 ways to deal with this: load every user reg hive and delete the keys, or increment the ActiveSetup version to run if there's a reinstall.  Both have challenges - dealing with locked hives or hives that don't unload, and having someone log in after the uninstall and trying to run the ActiveSetup are the first 2 that come to mind. 


Comments:
  • Oops, submitted too quickly. My client, who puts everything in a WinBatch wrapper, had me write a function that loads all the registry hives and delete the keys. In the strictest way of thinking, that would make sense as the best way to deal with ActiveSetup. - Arminius 12 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ