1. 程式人生 > >Inno Setup打包帶有MSI檔案的程式

Inno Setup打包帶有MSI檔案的程式

 1 [Files]
 2 Source: "C:\Documents and Settings\Administrator\桌面\4\abc.exe"; DestDir: "{app}"; Flags: ignoreversion
 3 Source: "C:\Documents and Settings\Administrator\桌面\4\vccrt8_Win32.msi"; DestDir: "{app}"; Flags: ignoreversion; AfterInstall: MyAfterInstall
 4 ; 注意: 不要在任何共享系統檔案上使用“Flags: ignoreversion”
5 6 [Icons] 7 Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 8 Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 9 10 [Run] 11 ;Filename: "msiexec.exe"; Parameters: "/i ""{app}\vccrt8_Win32.msi"" /quiet";Description:"安裝動態庫"; StatusMsg:"正在安裝必須的檔案"
12 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 13 14 [CODE] 15 procedure MyAfterInstall; 16 var 17 RetCode: integer; 18 begin 19 ShellExec('open', ExpandConstant('{app}\vccrt8_Win32.msi
'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, RetCode); 20 if RetCode <> 0 then 21 MsgBox(SysErrorMessage(RetCode), mbInformation, MB_OK); 22 end;

不知道為什麼Exec不成功,必須用ShellExec才可以。

另外,在[Run]下注釋的方法也是可行的,但