2012-02-16 151 views
6

我有以下代码与Inno安装程序。如何使用Inno安装程序处理.msi文件?

但我该如何将这个类似的功能应用于.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; 

回答

15

试试这个:

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}; 
+0

有什么办法可以自动卸载msi作为innosetup卸载例程的一部分吗? – Nyerguds 2013-03-07 11:40:49

3

注意说:我使用的是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 
5

建立在@ 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); 
+0

** [digitalextremist](http://stackoverflow.com/users/1169705/digitalextremist)**:在评论中发布代码块会删除换行符并使其很难阅读。但是,答案很清楚。 – 2014-01-28 03:17:24

+1

@digitalextremist:同意Alan,这段代码绝对不会令人愉快,作为评论的一部分。 – 2014-01-28 04:43:59

+1

@mike,显然kobik“没有显示整个代码”。这至多是一条评论......此外,让Windows Shell自己打开文件会更好吗?我的意思是,只是将MSI包文件名传递给'Filename'参数。如果安装了Windows安装程序并且MSI程序包已注册并由其执行,则Shell将处理此问题。 – TLama 2014-01-31 13:13:35

相关问题