【问题标题】:How to upgrade an MSI install using Inno Setup installer?如何使用 Inno Setup 安装程序升级 MSI 安装?
【发布时间】:2009-05-05 15:55:13
【问题描述】:
我们最近从基于 Visual Studio setup 的 msi 安装程序迁移到 Inno Setup,但我们在使用这个新安装程序升级现有安装时遇到了问题。我知道即使产品代码每次更新都会更改,升级代码仍然是静态的,因此我最初尝试将其设置为 Inno Setup 项目中的 AppId,但这不起作用。然后,我尝试了许多其他 guid,但都不起作用。
有没有办法使用 Inno Setup 安装程序正确升级 msi 安装?
【问题讨论】:
标签:
installation
windows-installer
inno-setup
【解决方案1】:
不,我不这么认为 - InnoSetup 明确不是基于 MSI 的安装程序。
您需要先正确卸载旧的基于 MSI 的安装,例如使用msiexec /X(产品代码或 MSI 文件名),然后您可以使用 InnoSetup 安装新的东西。
【解决方案2】:
要从 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
【解决方案3】:
我需要使用 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;
当然,用 MSI 包的产品 ID GUID 替换 {nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn}。