如何使用 Inno Setup 处理 .msi 文件?

发布于 2025-01-06 10:32:41 字数 647 浏览 0 评论 0原文

我使用 Inno Setup 编写了以下代码。

但如何将这个类似的功能应用于 .msi 文件呢?

msiexec /I“\package\file.msi”/qb?如何?

procedure AfterMyProgInstall(S: String);
var
  ErrorCode: Integer;
begin
  {MsgBox('Please wait the libraries are getting installed, ' +
          'without the libraries it wont work.', mbInformation, MB_OK);}
  ExtractTemporaryFile(S);
  {SW_SHOW, SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWMINIMIZED, SW_SHOWMINNOACTIVE, SW_HIDE}
  ShellExec('', ExpandConstant('{app}\package\' + S), '', '', SW_SHOWNORMAL,
            ewWaitUntilTerminated, ErrorCode);
end;

I have this following code with Inno Setup.

But how can I apply this similar function to .msi file?

msiexec /I "\package\file.msi" /qb? How?

procedure AfterMyProgInstall(S: String);
var
  ErrorCode: Integer;
begin
  {MsgBox('Please wait the libraries are getting installed, ' +
          'without the libraries it wont work.', mbInformation, MB_OK);}
  ExtractTemporaryFile(S);
  {SW_SHOW, SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWMINIMIZED, SW_SHOWMINNOACTIVE, SW_HIDE}
  ShellExec('', ExpandConstant('{app}\package\' + S), '', '', SW_SHOWNORMAL,
            ewWaitUntilTerminated, ErrorCode);
end;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

秋凉 2025-01-13 10:32:41

试试这个:

ShellExec('', 'msiexec.exe',
  ExpandConstant('/I "{tmp}\package\file.msi" /qb'),
  '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode);

或者:

[Files]
Source: file.msi; DestDir: {tmp}; Flags: deleteafterinstall;

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\file.msi"" /qb"; WorkingDir: {tmp};

Try this:

ShellExec('', 'msiexec.exe',
  ExpandConstant('/I "{tmp}\package\file.msi" /qb'),
  '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode);

Or:

[Files]
Source: file.msi; DestDir: {tmp}; Flags: deleteafterinstall;

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\file.msi"" /qb"; WorkingDir: {tmp};
云胡 2025-01-13 10:32:41

注意:我在 Windows 7 上使用 Inno Setup 5.5.3,并且此代码
用于运行部分中的 Inno Setup 脚本。使用此代码您可以
运行 msi 文件没有任何问题。这是代码:

[Run]
Filename: `{src}\PhysX.msi;` Description: Nvidia PhysX; Verb: open; Flags: shellexec postinstall waituntilterminated runascurrentuser skipifsilent

Note that: I'm using Inno Setup 5.5.3 on Windows 7, and that this code
is for the Inno Setup script in the run section. With this code you can
run msi files without any problems. Here is the code:

[Run]
Filename: `{src}\PhysX.msi;` Description: Nvidia PhysX; Verb: open; Flags: shellexec postinstall waituntilterminated runascurrentuser skipifsilent
一场信仰旅途 2025-01-13 10:32:41

基于@kobik 给出的答案。我必须在文件名中包含“.exe”。
就像这样:

if not ShellExec('', 'msiexec.exe', ExpandConstant('{tmp}\package\file.msi'),
  '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode)
then
  MsgBox('Msi installer failed to run!' + #13#10 + ' ' +
    SysErrorMessage(ErrorCode), mbError, MB_OK);

Building on the answer @kobik gave. I had to include the '.exe' in the Filename.
Like so:

if not ShellExec('', 'msiexec.exe', ExpandConstant('{tmp}\package\file.msi'),
  '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode)
then
  MsgBox('Msi installer failed to run!' + #13#10 + ' ' +
    SysErrorMessage(ErrorCode), mbError, MB_OK);
心病无药医 2025-01-13 10:32:41

虽然kobik在运行部分使用“msiexec.exe /i”的选项通常有效,但我们遇到了管理员权限降级的问题:

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\file.msi"" /qb"; WorkingDir: {tmp};

当msiexec.exe /i file.msi以这种方式运行时,它会使用UAC请求管理员权限(如预期的,在我们的例子中确实需要)。但在这个安装部分中间的某个地方,当“file.msi”尝试启动 Windows 服务时,它似乎已被正确降级,并且没有足够的权限来启动 Windows 服务。
然而,当它通过 shellexec 启动时,一切正常,没有这个问题。这就是它对我的作用:

[Run]
Filename: "{tmp}\file.msi"; Flags: skipifsilent shellexec waituntilterminated hidewizard; 

Although kobik's option to use "msiexec.exe /i" in Run section generally works, we faced a problem of admin right downgrade with it:

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\file.msi"" /qb"; WorkingDir: {tmp};

When msiexec.exe /i file.msi runs this way it requests the admin rights with UAC (as expected, it is really required in our case). But somewhere in the middle of this installation part when "file.msi" is trying to start a windows service it appeared to be right-downgraded and have not enough privileges to start windows service.
However when it's launched via shellexec it goes ok without this problem. So this is how it worked to me:

[Run]
Filename: "{tmp}\file.msi"; Flags: skipifsilent shellexec waituntilterminated hidewizard; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文