cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sirhaden
Level 3

Uninstall Reg Keys

How should one go about creating an installation that does nothing to the registry during initial installation or maintenance, but deletes specified registry keys during uninstall?

The same functionality should work if the uninstall is invoked from the Control Panel or via the InstallShield installation file.
Labels (1)
0 Kudos
(2) Replies
Holger_G
Level 10

Which project type do you use?
For Basic MSI you might take a look at the RemoveRegistry Table.
0 Kudos
sirhaden
Level 3

It is a Basic MSI installation. I've gotten as far as creating a custom action with an InstallShield script that only gets executed during an uninstall. The script first attempts to delete the keys under HKLM and then the keys under HKCU. The keys under HKCU are successfully deleted, but the keys under HKLM fail to delete. It seems as if the uninstall (invoked from the control panel) is not running the script with elevated admin privileges. The installation is being run on Windows 7 x64. And this is the current script:

function DeleteRegKeys(hMSI)
// To Do: Declare local variables.
begin

// HKEY_LOCAL_MACHINE
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

if(RegDBDeleteKey("Software\\Wow6432Node\\My Company") < 0) then
MessageBox("RegDBDeleteKey(Software\\Wow6432Node\\My Company) FAILED", SEVERE);
else
MessageBox("RegDBDeleteKey(Software\\Wow6432Node\\My Company) SUCCEEDED", INFORMATION);
endif;

if(RegDBDeleteKey("Software\\My Company") < 0) then
MessageBox("RegDBDeleteKey(Software\\My Company) FAILED", SEVERE);
else
MessageBox("RegDBDeleteKey(Software\\My Company) SUCCEEDED", INFORMATION);
endif;


// HKEY_CURRENT_USER
RegDBSetDefaultRoot(HKEY_CURRENT_USER);

if(RegDBDeleteKey("Software\\My Company") < 0) then
MessageBox("RegDBDeleteKey(Software\\My Company) FAILED", SEVERE);
else
MessageBox("RegDBDeleteKey(Software\\My Company) SUCCEEDED", INFORMATION);
endif;

end;
0 Kudos