cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jstarbird
Level 5

Registry issues on uninstall - basic msi

I have a Basic MSI and have component that is not shared and not permanent and the registry entries are under that component. I left the entries with the default Automatic setting but on uninstall the entry is not being deleted even though the components files all are.
The only way I could get it to remove it was to set it to Uninstall Entire Key setting, the Install if absent, Uninstall if present also did not uninstall correctly.
I then also tried creating an InstallScript custom action and called RegDbDeleteKey and when that runs I get a weird error, when put thru FormatMessage, of "The system cannot find the file specified." which of course for registry makes zero sense.
This is on Windows 7 and the area is in HKCU and rights/permissiosn are not an issue. Also in the same InstallScript function I make a call to HKLM and that one works just fine. This is set to run as Deferred in System Context.
Here is the installscript code I am using for this:

function CleanupRegistry(hMSI)
STRING svKey, szErrString, svPVer;
NUMBER nResult, nRootKey;
begin
svKey = "SOFTWARE\\"+ IFX_COMPANY_NAME +"\\"+ IFX_PRODUCT_NAME +"\\";
svPVer = "v0"+IFX_PRODUCT_VERSION;

nRootKey = HKEY_LOCAL_MACHINE;
RegDBSetDefaultRoot(nRootKey);
if (RegDBKeyExist(svKey) == 1) then
nResult = RegDBDeleteKey(svKey);
if (nResult < 0) then
szErrString = FormatMessage(nResult);
MessageBox("Unable to delete registry key - HKEY_LOCAL_MACHINE\\"+ svKey +"\n"+ szErrString, WARNING);
endif;
endif;

nRootKey = HKEY_CURRENT_USER;

RegDBSetDefaultRoot(nRootKey);
svKey = "Software\\"+ IFX_COMPANY_NAME +"\\"+ IFX_PRODUCT_NAME +"\\";
if (RegDBKeyExist(svKey) == 1) then
nResult = RegDBDeleteKey(svKey);
if (nResult < 0) then
szErrString = FormatMessage(nResult);
MessageBox("Unable to delete registry key - HKEY_CURRENT_USER\\"+ svKey +"\n"+ szErrString, WARNING);
endif;
endif;
end;


Has anyone seen this kind of thing with InstallShield 2012 Sp1?


Thanks,
J
Labels (1)
0 Kudos
(2) Replies
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

When running deferred in system context actions, the custom action is running in the LocalSystem account. As such, HKEY_CURRENT_USER is not the same as it would be when launching regedit on the machine (it would be HKCU for LocalSystem, not the logged on/launching user). Therefore, the key(s) would likely not be found. If you are just trying to remove keys from HKCU, a normal deferred action should be sufficient (since the current user has rights to modify their registry).

Regarding the original issue, what is the action state of the component that contains this registry information listed in a verbose log? Is the user that is running the uninstall the same user that originally installed this package?
0 Kudos
jstarbird
Level 5

thanks, that makes sense on the deferred with system point.
To answer your question, yes it is the same user. I can get that result if I run the install and then immediatly uninstall. I finally got it to sort of work by taking it out from under a component and mapping it in the main project registry settings. Once I did that it would at least act correctly but only if the registry was empty below the main key.

Anyway, changing the one to Deferred alone did make it work so that is sufficient for my needs.

Thanks,
J
0 Kudos