2009-03-05 74 views
-1

我們開發的產品由客戶分發給客戶。我們需要允許客戶公司的管理員在將其發送給最終用戶之前對安裝程序進行配置更改。這種情況下的配置更改意味着要在最終用戶計算機上創建一對註冊表項。我該怎麼做呢?分銷前配置安裝程序

回答

2

這裏是我們送出去給客戶一個示例腳本。他們創建一個自定義配置文件,運行這個腳本,並最終得到一個MST和一個CAB,它將覆蓋基本MSI中包含的默認值。

最初我們只是給了客戶使用Orca的說明,但它確實只能讓他們更新屬性/值 - 如果您需要替換配置文件,那麼對於大多數IT人員來說,結果有點複雜,除非他們有權訪問WISE,InstallShield或類似的。

Option Explicit 

Const MSI_SRC = "myapp.msi" 
Const MSI_TEMP = "temp.msi" 
Const MST_FILE = "custom.mst" 
Const MY_CONFIG = "customsettings.reg" 
Const CAB_FILE = "config.cab" 

Dim filesys 
Set filesys=CreateObject("Scripting.FileSystemObject") 

If filesys.FileExists(MSI_SRC) Then 
    filesys.CopyFile MSI_SRC, MSI_TEMP 
Else 
    MsgBox "Unable to find " & MSI_SRC & "exiting", 48, "Fatal Error" 
    Set filesys = Nothing 
    WScript.Quit 
End If 

If filesys.FileExists(MST_FILE) Then 
    filesys.DeleteFile(MST_FILE) 
End If 


Dim installer, database, database2, view 

Set installer = CreateObject("WindowsInstaller.Installer") 
Set database = installer.OpenDatabase (MSI_TEMP, 1) 
Set database2 = installer.OpenDatabase (MSI_SRC, 1) 

If filesys.FileExists(MY_CONFIG) Then 
    Dim objFile, size, result, seq, objCab 
    Set objCab = CreateObject("MakeCab.MakeCab.1") 
    objCab.CreateCab CAB_FILE, False, False, False 
    objCab.AddFile MY_CONFIG, filesys.GetFileName(MY_CONFIG) 
    objCab.CloseCab 

    Set objFile = filesys.GetFile(MY_CONFIG) 
    size = objFile.Size 

    Set view = database.OpenView ("SELECT LastSequence FROM Media WHERE DiskId = 1") 
    view.Execute 
    Set result = view.Fetch 
    seq = result.StringData(1) + 1 ' Sequence for new configuration file 

    Set view = database.OpenView ("INSERT INTO Media (DiskId, LastSequence, Cabinet) VALUES ('2', '" & seq & "', '" & CAB_FILE & "')") 
    view.Execute 

    Set view = database.OpenView ("UPDATE File SET FileSize = " & size & ", Sequence = " & seq & ", FileName = 'CUSTOM~2.REG|customsettings.reg' WHERE File = '" & LCase(MY_CONFIG) & "'") 
    view.Execute 
End If 


database.GenerateTransform database2, MST_FILE 
database.CreateTransformSummaryInfo database2, MST_FILE, 0, 0 

' Cleanup 
Set database = Nothing 
Set database2 = Nothing 
Set installer = Nothing 
Set view = Nothing 

filesys.DeleteFile(MSI_TEMP) 
Set filesys = Nothing 
+0

您好sascha:您發佈的腳本解決方案正是我一直在尋找的。我的腳本運行時沒有任何錯誤,更新了msi上的修改日期。我試着修改兩個不同的文件。 1)logo2.gif當我運行安裝程序時出現錯誤:「安裝程序在安裝此程序包時遇到意外錯誤,這可能表示此程序包有問題,錯誤代碼爲2755。然後,「從服務器返回,返回值:110」。然後我試着和ascii配置文件。之後,我能夠安裝沒有錯誤...但安裝的文件不是更新的:( – blak3r 2009-05-23 07:03:36