We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

adamdc78
Posts: 76
Joined: Wed Mar 19, 2014 7:42 pm

Removing Registry Values during Uninstallation

Several registry values are created at run time in the application which I need to clean up during uninstallation.

I cannot simply remove the registry key.

I've written an executable tool to handle the clean up but run into the issue that the entire key (as well as dozens of others) under HKCU are not readable during the uninstallation; I've written a vb script to test whether the key is readable at different times during the uninstallation as well and cannot seem to find them if my action is run as deferred or commit.

If I run the vbscript or .exe on their own, everything works as expected. I imagine my issue is that msiexec is locking out these keys (for some reason I cannot understand as only 1 of them is relevant to my application), but was wondering whether there is a well known timing for registry value edits?

Of note: the HKLM hive doesn't give me any problems.

The vbscript I'm running to test the readability of the key:

Code: Select all

option explicit

dim oShell, sKey, strKeyPath, reg, strComputer
Const HKEY_CURRENT_USER = &H80000001
strKeyPath = "Software"
strComputer = "."

Set reg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_ 
    strComputer & "\root\default:StdRegProv")

EnumerateKeys HKEY_CURRENT_USER, strKeyPath

Sub EnumerateKeys(hive, key)
  Dim success, arrSubKeys, subkey
  success = reg.EnumKey(hive, key, arrSubKeys)
  If Not IsNull(arrSubKeys) Then
    For Each subkey In arrSubKeys
	   If subkey = "MyKey" Then
        MsgBox subkey
	   End If
    Next
  End If
End Sub
I've tried running between Preparing and Remove Resources and Remove Resources and Add Resources, deferred and commit (no impersonation in all cases) and have had no luck anywhere.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Removing Registry Values during Uninstallation

Hello,

This may happen if you have enabled the "Run under the LocalSystem account with full privileges (no impersonation)" execution option for your custom action.
If this is the case, can you please uncheck the above option (so that the custom action search under the HKCU hive of the current installing user) and see if the behavior still persists? If so, please send us the .aip (project file) to support at advancedinstaller dot com so we can investigate its settings?

Also, if you need to remove registry values created after installation by your application, then you can use a registry removal operation or our registry key removal support.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
adamdc78
Posts: 76
Joined: Wed Mar 19, 2014 7:42 pm

Re: Removing Registry Values during Uninstallation

It clicked as soon as I started to read it. Of course HKCU is different for the local system account... Thank you very much!
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Removing Registry Values during Uninstallation

You're always welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”