如何使用 Inno Setup 处理 .msi 文件?
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个:
或者:
Try this:
Or:
注意:我在 Windows 7 上使用 Inno Setup 5.5.3,并且此代码
用于运行部分中的 Inno Setup 脚本。使用此代码您可以
运行
msi
文件没有任何问题。这是代码: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:基于@kobik 给出的答案。我必须在文件名中包含“.exe”。
就像这样:
Building on the answer @kobik gave. I had to include the '.exe' in the Filename.
Like so:
虽然kobik在运行部分使用“msiexec.exe /i”的选项通常有效,但我们遇到了管理员权限降级的问题:
当msiexec.exe /i file.msi以这种方式运行时,它会使用UAC请求管理员权限(如预期的,在我们的例子中确实需要)。但在这个安装部分中间的某个地方,当“file.msi”尝试启动 Windows 服务时,它似乎已被正确降级,并且没有足够的权限来启动 Windows 服务。
然而,当它通过 shellexec 启动时,一切正常,没有这个问题。这就是它对我的作用:
Although kobik's option to use "msiexec.exe /i" in Run section generally works, we faced a problem of admin right downgrade with it:
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: