I want to make 2 installer, one to install and one to update an application.
Both installers uses the same AppId
string, but only the install asks to user where install the application (DirName
).
I expect that the update installer will get the same installation folder without selecting it.
Both installers should be not uninstallable.
Installer config:
[Setup]
AppId=MyApp
DefaultDirName={sd}\myapp
ChangesEnvironment=yes
PrivilegesRequired=admin
Uninstallable=no
ArchitecturesInstallIn64BitMode=x64
SignTool=signtool
And this is the Update config:
[Setup]
AppId=MyApp
DefaultDirName={sd}\myapp
CloseApplications=no
DisableProgramGroupPage=yes
UsePreviousAppDir=yes
ChangesEnvironment=yes
PrivilegesRequired=admin
Uninstallable=no
ArchitecturesInstallIn64BitMode=x64
When I use the installer and updater with the default DirName
it works well. But if I change manually the installation folder at installation time, then the update will not find the folder of the application.
I checked in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
but I cannot find any registry about my installation.
Is it possible the the option Uninstallable=no
makes unavailable the previous dirname?
Yes, with the Uninstallable=no
, no metadata are saved. You have to save/restore the path somewhere in your own code.
For example:
CurStepChanged(ssDone)
using RegWriteStringValue
.DefaultDirName
directive using RegQueryStringValue
[Setup]
DefaultDirName={code:GetDefaultDirName}
Uninstallable=no
[Code]
const
SubKeyName = 'Software\My Company\My Program';
ValueName = 'InstallLocation';
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssDone then
begin
RegWriteStringValue(
HKEY_AUTO, SubKeyName, ValueName, ExpandConstant('{app}'));
end;
end;
function GetDefaultDirName(Param: string): string;
begin
if not RegQueryStringValue(HKEY_AUTO, SubKeyName, ValueName, Result) then
Result := ExpandConstant('{autopf}\My Program');
end;