PDA

View Full Version : Uninstall registry w. UninstallData does not work


SetupJuggler
11-17-2008, 11:04 AM
I'm Using SUF 8.1.1006.0

I used the example from http://www.indigorose.com/forums/showthread.php?t=19372&highlight=UninstallData to create my uninstall within <On Post Install> action. If I examine my Setup the registry entry is added to the registry, but on uninstall I got the error 1601.


Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\_Company\\Product\\logging", "logfile", "C:\\logbook\\automated\\log.txt", REG_SZ);
-- Now update the uninstall so that the above registry value get deleted
sItemData = {ID="UISCRIPT_001", Timing=4, Script="Registry.DeleteKey(HKEY_LOCAL_MACHINE, \"SOFTWARE\\_Company\\Product\\logging\");"};
UninstallData.AddItem(UNINDATA_SCRIPTS, sItemData);


The Uninstall logfile shows
...
[11/17/2008 16:47:47] Error Script: Extra Script: UISCRIPT_001, Line 1 (1601)
[11/17/2008 16:47:47] Success Run extra uninstall script: 4
...

The example project and the log files are attached.

Any idea what's wrong.

upeters
11-19-2008, 01:53 PM
Ok, here is what I did:

I created a script file named "uninstall.lua", containing the code below, and included it under Resources > Scripts.
function cleanup()
-- remove just the "logfile" value
Dialog.Message("deleting value", SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%\\logging"), MB_OK);
Registry.DeleteValue(HKEY_LOCAL_MACHINE, SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%\\logging"), "logfile");

-- remove the whole "%ProductName%" key
Dialog.Message("deleting key", SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%"), MB_OK);
Registry.DeleteKey(HKEY_LOCAL_MACHINE, SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%"));
end
In On Post Install I placed the following code:

Registry.SetValue(HKEY_LOCAL_MACHINE, SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%\\logging"), "logfile", SessionVar.Expand("%AppFolder%\\logbook\\automated\\log.txt"), REG_SZ);

-- Now update the uninstall so that the above registry value get deleted
sItemData = {ID="myscript", Timing=4, Script="cleanup();"};
UninstallData.AddItem(UNINDATA_SCRIPTS, sItemData);


When uninstalling, you will get two dialogs for debugging purposes. Once everything works as it should, comment them out or remove them. The removal of the key will remove the value as well, of course, so the first step isn't really required but included for demonstration only.


Ulrich

SetupJuggler
11-20-2008, 11:07 AM
Thanks, Ulrich.

Tried it out and worked fine. That's it.
But I have to handle round about 50 registry entries, so I won't create a lot of special lua-function. So I tried the cleanup() function with parameters. And oops the parameter string lost its backslashes. that's the real bug. So I have to try why my string "Software\\_Company\\Product" went to "Software_CompanyProduct".

Any idea? More backslashes? Or is it such a hard bug, no workaround exists.

SetupJuggler
11-21-2008, 06:35 AM
Hi Ulrich,
your cleanup script inspires me Thank's a lot.:)
Tried it with dublicated quotes, and oh suprise, that works fine.


Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\_Company\\Product\\logging", "logfile", "C:\\logbook\\automated\\log.txt", REG_SZ);
-- Now update the uninstall so that the above registry value get deleted
-- 4 backslashes needed within script command string to work fine
sItemData = {ID="UISCRIPT_001", Timing=4, Script="Registry.DeleteKey(HKEY_LOCAL_MACHINE, \"SOFTWARE\\\\_Company\\\\Product\\\\logging\");"};
UninstallData.AddItem(UNINDATA_SCRIPTS, sItemData);


Now I may solve my task with my 50 registry entries. Some of them have to be expanded during install, some of them have to be left after uninstall.

Udo