简体   繁体   中英

How to handle the .msi file with Inno Setup?

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;

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

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

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);

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; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM