Annoyingly I specified the uninsdeletekey
flag in my installer:
Root: "HKA"; Subkey: "Software\Company\Application"; Flags: uninsdeletekey
Similar questions:
The second question is more related to my issue. But I am not in a position to modify any uninstaller, as proposed in the answer.
It has been like this for 20 years! But I have now created two installers for the same program. One for 32/64 respectively and during installer they remove the old application.
On the upside,no user data is lost. On the down down, all data in registry is lost. I had a look at the command line switches for the uninstaller and there seems to be nothing to prevent this happening.
At the moment the only solution I can think of is:
Am I reinventing the wheel here? I am trying to see if there is an existing elegant solution to this problem.
If I didn’t do that all the settings would still be there.
I stumbled on this question:
In one of the answers it says about using reg.exe
to export the key. So my updated idea now is:
reg.exe
with original user account if possible to create the file.reg.exe
to import it.Either that or write my own tool to do the same.
I confirm that step one works:
ExecAsOriginalUser(ExpandConstant('{sys}\reg.exe'), \
'export "HKEY_CURRENT_USER\Software\Company\Application" "d:\test.txt"', \
'', SW_HIDE, ewWaitUntilTerminated, ExportRegResult);
Log(SysErrorMessage(ExportRegResult));
But I hardcoded it with a d:\test.txt
. I can't find out how to get a temporary file name, for us to copy into the user data folder at the end of the installation.
Imo, that's the best solution (or don't run the old uninstaller)
To get a path to a temporary folder, to temporarily store the registry, use {tmp}
constant:
ExpandConstant('{tmp}\backup.reg')
Additionally, the ExecAsOriginalUser
and HKEY_CURRENT_USER
do not match with the HKA
Registry
entry in your old (un)installer.
Imo you should:
Exec
– to run the reg
with the same privileges and under the same account with which your old (un)installer operates.HKEY_LOCAL_MACHINE
when IsAdminInstallMode
is true – to match HKA
behaviour.For some examples of reg.exe
error handling from Inno Setup, see:
Creating registry key for logged in user (not admin user) in Inno Setup