我们最近从基于 Visual Studio 设置 msi 的安装程序转移到 Inno Setup,但我们在使用这个新安装程序升级现有安装时遇到了问题。我知道即使产品代码每次更新都会更改,升级代码仍然是静态的,所以我最初尝试将其设置为 Inno Setup 项目中的 AppId,但这不起作用。然后我尝试了一些其他的 guid 都不起作用。
有没有办法使用 Inno Setup 安装程序正确升级 msi 安装?
我们最近从基于 Visual Studio 设置 msi 的安装程序转移到 Inno Setup,但我们在使用这个新安装程序升级现有安装时遇到了问题。我知道即使产品代码每次更新都会更改,升级代码仍然是静态的,所以我最初尝试将其设置为 Inno Setup 项目中的 AppId,但这不起作用。然后我尝试了一些其他的 guid 都不起作用。
有没有办法使用 Inno Setup 安装程序正确升级 msi 安装?
不,我不这么认为——InnoSetup 显然不是基于 MSI 的安装程序。
您需要首先使用例如 msiexec /X(产品代码或 MSI 文件名)正确卸载旧的基于 MSI 的安装,然后您可以使用 InnoSetup 安装新的东西。
要从 Inno Setup 安装中安装 .MSI 文件,请尝试以下几行:
[Files]
Source: "Your-MSI-File.msi"; DestDir: "{tmp}"
[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\Your-MSI-File.msi"""
Alex Yackimoff 的学分 http://www.jrsoftware.org/iskb.php?msi
我需要使用 MSI 包(替换为 Inno Setup 安装程序)来执行此操作。我在 Inno Setup 安装程序中使用以下代码在安装时自动卸载 MSI 包(如果已安装):
function PrepareToInstall(var NeedsRestart: Boolean): string;
var
OldAppGuid, SubKeyName: string;
OldAppFound: Boolean;
ResultCode: Integer;
begin
NeedsRestart := false;
result := '';
if IsAdminInstallMode() then
begin
OldAppGuid := '{nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn}';
SubKeyName := 'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' + OldAppGuid;
OldAppFound := RegKeyExists(HKEY_LOCAL_MACHINE, SubKeyName);
if not OldAppFound then
begin
SubKeyName := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + OldAppGuid;
OldAppFound := RegKeyExists(HKEY_LOCAL_MACHINE, SubKeyName);
end;
if OldAppFound then
begin
Exec(ExpandConstant('{sys}\msiexec.exe'), // Filename
'/X ' + OldAppGuid + ' /qb- REBOOT=ReallySuppress', // Params
'', // WorkingDir
SW_SHOW, // ShowCmd
ewWaitUntilTerminated, // Wait
ResultCode); // ResultCode
end;
end;
end;
当然,替换{nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn}
为 MSI 包的产品 ID GUID。