2014-10-29 166 views
0

我使用exemsi.com的'MSI Wrapper v5.1.89.0'轉換使用'Inno Setup Compiler v5.5.5(a)'創建的安裝。將多個安裝包裝到MSI中

的安裝腳本如下:

[Setup] 
AppName=Personal Time Keeping 
AppVersion=1.0.2.1 
DefaultDirName={pf}\PTK 
DefaultGroupName=group name 
UninstallDisplayIcon={app}\ptk.exe 
Compression=lzma2 
SolidCompression=yes 
OutputDir=userdocs:Inno Setup Examples Output 
; "ArchitecturesInstallIn64BitMode=x64" requests that the install be 
; done in "64-bit mode" on x64, meaning it should use the native 
; 64-bit Program Files directory and the 64-bit view of the registry. 
; On all other architectures it will install in "32-bit mode". 
ArchitecturesInstallIn64BitMode=x64 
; Note: We don't set ProcessorsAllowed because we want this 
; installation to run on all architectures (including Itanium, 
; since it's capable of running 32-bit code too). 

[InstallDelete] 
Type: files; Name: "{userappdata}\Microsoft\Windows\Start Menu\Programs\Startup\ptk.exe - Shortcut.lnk" 

[Files] 
;Ensure all the prerequisites are installed 
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\NDP451-KB2858728-x86-x64-AllOS-ENU.exe"; Check: needsFramework; DestDir: "{tmp}"; DestName: "NDP451.exe"; Flags: deleteafterinstall; 
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\VisualBasicPowerPacks3Setup.exe"; Check: needsPowerPacks; DestDir: "{tmp}"; DestName: "VBPP3.exe"; Flags: solidbreak 
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\sharepointclientcomponents_x64.msi"; Check: (IsWin64 and needsSharePtClient); DestDir: "{tmp}"; DestName: "sharept.msi"; Flags: solidbreak 
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\sharepointclientcomponents_x86.msi"; Check: ((not IsWin64) and needsSharePtClient); DestDir: "{tmp}"; DestName: "sharept.msi"; Flags: solidbreak 
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\mysql-connector-net-6.8.3.msi"; Check: needsMySQLNET; DestDir: "{tmp}"; DestName: "mysqlNET.msi"; Flags: solidbreak 
Source: "C:\3subTimeKeeingApp\3sunptk\prerequisites\mysql-connector-odbc-5.3.2-win32.msi"; Check: needsMySQLODBC; DestDir: "{tmp}"; DestName: "mysqlODBC.msi"; Flags: solidbreak 
;The application to install 
Source: "C:\3subTimeKeeingApp\3sunptk\3sunptk\bin\Release\3sunptk.exe"; DestDir: "{app}"; BeforeInstall: CloseApp('3sunptk.exe'); 
;Transfer reports folders and files 
Source: "C:\3subTimeKeeingApp\3sunptk\report\*"; DestDir: "{app}\report"; Flags: ignoreversion recursesubdirs 

[Run] 
;Uninstall of older verison of 'Personal TimeKeeping' application 
Filename: "{sys}\rundll32.exe"; Parameters: "dfshim.dll,ShArpMaintain 3sunptk.application, Culture=en-GB, PublicKeyToken=077ce3637efc8b1c, processorArchitecture=msil"; Check: isOldStyleInstalled; StatusMsg: Uninstalling older version of Personal Timekeeping; Flags: runascurrentuser; 
;Install the MSI's quietly "/passive /norestart /q:a /c:""install /l /q""" 
Filename: {tmp}\NDP451.exe; Parameters: "/passive /norestart /c:""install /l /q"""; StatusMsg: Microsoft Framework 4.5.1 is being installed. Please wait..     
Filename: "{tmp}\VBPP3.exe"; Parameters: "/s /v""/qb"""; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: Installing Visual Basic Power Packs 3. 
Filename: "msiexec.exe"; Parameters: "/quiet /i ""{tmp}\sharept.msi"""; StatusMsg: Installing Sharepoint client tools. 
Filename: "msiexec.exe"; Parameters: "/quiet /i ""{tmp}\mysqlNET.msi"""; StatusMsg: Installing mySQL .NET connector. 
Filename: "msiexec.exe"; Parameters: "/quiet /i ""{tmp}\mysqlODBC.msi"""; StatusMsg: Installing mySQL ODBC connector. 
;Start the application 
Filename: "{app}\3sunPTK.exe"; Description: "Launching 3sun Personal Timekeeping"; Flags: nowait postinstall skipifsilent; 

[Icons] 
Name: "{commonstartup}\3sun Personal Timekeeping"; Filename: "{app}\3sunPTK.exe" 

[Code] 
//-------------------------------------------------------------------------------- 
// Visual Basic Power Packs 
//-------------------------------------------------------------------------------- 
function isVBPowerPacks3installed(): Boolean; 
    var 
     success: Boolean; 
     productName: String; 
    begin 
     success := RegQueryStringValue(HKCU, 
      'Software\Microsoft\Installer\Products\B391D4B7D67DB803B821D5B91BBCECC6', 
      'ProductName', 
      productName); 
     Result := success and (productName = 'Microsoft Visual Basic Power Packs 3.0'); 
    end; 

function needsPowerPacks(): Boolean; 
    begin 
     Result := (isVBPowerPacks3installed = False); 
    end; 
//-------------------------------------------------------------------------------- 
// .NET helpers 
//-------------------------------------------------------------------------------- 
function isDotNet451Detected(): Boolean; 
    var 
     success: Boolean; 
     release: Cardinal; 
    begin 
     success := RegQueryDWordValue(HKLM, 
        'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\', 
        'Release', 
        release); 
//For .net versions 
//http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx#net_b 
     Result := success and (release = 378758); 
    end; 

function needsFramework(): Boolean; 
    begin 
     Result := (isDotNet451Detected = False); 
    end; 
//-------------------------------------------------------------------------------- 
// MySQL .NET connector 6.8.3 
//-------------------------------------------------------------------------------- 
function isMySQLNETconnectorInstalled(): Boolean; 
    var 
     success: Boolean; 
     version: String; 
    begin 
     success := RegQueryStringValue(HKLM, 
        'SOFTWARE\Wow6432Node\MySQL AB\MySQL Connector/Net\', 
        'Version', 
        version); 
     Result := success and (CompareStr(version, '6.8.3') = 0); 
    end; 

function needsMySQLNET(): Boolean; 
    begin 
     Result := (isMySQLNETconnectorInstalled = False); 
    end; 
//-------------------------------------------------------------------------------- 
// MySQL ODBC Connector 5.3 
//-------------------------------------------------------------------------------- 
function isMySQLODBCconnectorInstalled(): Boolean; 
    var 
     success: Boolean; 
     version: String; 
    begin 
     success := RegQueryStringValue(HKLM, 
         'SOFTWARE\MySQL AB\MySQL Connector/ODBC 5.3\', 
         'Version', 
         version); 
     Result := success and (CompareStr(version, '5.3.2') = 0); 
    end; 

function needsMySQLODBC(): boolean; 
    begin 
     Result := (isMySQLODBCconnectorInstalled = False); 
    end; 
//-------------------------------------------------------------------------------- 
// Sharepoint client components 
//-------------------------------------------------------------------------------- 
function isSharepointClientInstalled(): Boolean; 
    begin 
     Result := RegKeyExists(HKLM, 'SOFTWARE\Microsoft\SharePoint Client Components'); 
    end; 

function needsSharePtClient(): Boolean; 
    begin 
     Result := (not isSharepointClientInstalled); 
    end; 
//-------------------------------------------------------------------------------- 
// Checks if the application is installed witht the old style installation 
//-------------------------------------------------------------------------------- 
function isOldStyleInstalled(): Boolean; 
    var 
     success: Boolean; 
     uninstall: String; 
    begin 
     success := RegQueryStringValue(HKCU, 
         'Software\Microsoft\Windows\CurrentVersion\Uninstall\4f2a8fa50dcb64ac', 
         'UninstallString', 
         uninstall); 
     Result := success and (Length(uninstall) > 0); 
    end; 
//-------------------------------------------------------------------------------- 
// Close application 
//-------------------------------------------------------------------------------- 
const wbemFlagForwardOnly = $00000020; 
procedure CloseApp(AppName: String); 
    var 
     WbemLocator : Variant; 
     WMIService : Variant; 
     WbemObjectSet: Variant; 
     WbemObject : Variant; 
    begin; 
     WbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); 
     WMIService := WbemLocator.ConnectServer('localhost', 'root\CIMV2'); 
     WbemObjectSet := WMIService.ExecQuery('SELECT * FROM Win32_Process Where Name="' + AppName + '"'); 
     if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then 
      begin 
       WbemObject := WbemObjectSet.ItemIndex(0); 
       if not VarIsNull(WbemObject) then 
        begin 
         WbemObject.Terminate(); 
         WbemObject := Unassigned; 
        end; 
      end; 
    end; 

時與setup.exe運行,但在作爲運行的setup.msi,它多遠的.dotNET框架4.5這工作得很好沒有問題。 1然後想要等待另一個設置完成,我沒有看到。最終它會結束,但不會安裝任何框架或MSI。

+0

發現這一點: http://stackoverflow.com/questions/16530866/installshield-with-net-4-5-nested-installation – SPlatten 2014-10-29 10:08:41

+0

可悲的是這種解決方案不起作用,嘗試使用啓動MSI:MSIEXEC .exe/quiet/i netfx_Full_x64.msi不起作用。 – SPlatten 2014-10-29 10:19:04

回答

0

將EXE包裝到MSI中是一種不好的做法,因爲它會創建所謂的「特洛伊木馬」MSI。它似乎是一個MSI,但沒有任何MSI的優勢或一致性。 .NET Framework安裝程序是一個在內部調用多個MSI/MSP的EXE。您無法將MSI包裝到MSI中,因爲存在防止此問題的系統級互斥體。

我建議你看看InstallShield Suite Installers或Windows Installer XML Burn之類的東西,以創建一個引導程序將這些軟件包鏈接在一起。

+0

我使用MS Visual Studio 2013,出於某種原因,該框架不可用作MSI,而IT部門只能使用MSI的組策略。 – SPlatten 2014-10-30 16:09:44

+0

組策略部署的功能非常有限。你的設計不會修復那個盒子。 – 2014-10-30 17:33:57

+0

令我驚訝的是,.NET框架只能以.EXE安裝的形式提供,因爲組策略只能推出MSI。 – SPlatten 2014-10-31 08:35:43