Windows installer error, Error Code : 2869

在 Windows 7 下,安裝一 *.msi 程式,運行時卻產生錯誤:2869.

這問題要如何排除?

Google 一下,得到一文章:
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/c1326233-3f10-4d98-96a7-4a22e5eeaa2d/

提到,先建置一 vbs 檔案,以修正環境的設定值。其方法如下:
1. 建置 NoImpersonate.vbs (本文的後端會詳述內容)
2. 運行 VBS。
    cscript NoImpersonate.vbs <msi-file>
    ex: cscript NoImpersonate.vbs "Lorom ERP Develop Setup.msi"
3. 再重新執行一次 MSI。

check this link : http://msdn2.microsoft.com/en-us/library/aa368069.aspx

NoImpersonate.vbs 程式碼,條列
'------------------------------------------------
Option Explicit
'' Constant values from Windows Installer
Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Const msiViewModifyAssign = 3
Const msiViewModifyReplace = 4
Const msiViewModifyDelete = 6
Const msidbCustomActionTypeInScript = &H00000400
Const msidbCustomActionTypeNoImpersonate = &H00000800

Dim databaseFile
Dim installer : Set installer = Nothing
Dim database : Set database = Nothing
Dim sql
Dim View, Record
Dim openMode : openMode = msiOpenDatabaseModeTransact
On Error Resume Next

Call Main()

Sub Main()
   If WScript.Arguments.Length <> 1 Then
      Fail("Usage is: cscript " & WScript.ScriptName & " [msi file]")
   End If
   databaseFile = WScript.Arguments(0)
   'WScript.Echo(WScript.ScriptName & ": operating on file '" & databaseFile & "'")
   '' Instantiate Windows Installer object
   Set installer = WScript.CreateObject("WindowsInstaller.Installer") : CheckError
   '' Open the MSI database
   Set database = installer.OpenDatabase(databaseFile, openMode) : CheckError
   Proc1 : CheckError
   'Proc2 : CheckError
   If openMode = msiOpenDatabaseModeTransact Then
      database.Commit
   End If
   WScript.Quit 0
End Sub

Sub Proc1()
   '' 1. problem: CustomActions in Vista have to run with NoImpersonate
   sql = "SELECT `Action`, `Type`, `Source`, `Target` FROM `CustomAction`"
   Set View = database.OpenView(sql) : CheckError
   View.Execute : CheckError
   Do
      Set Record = View.Fetch
      If Record Is Nothing Then Exit Do
      'typeVal = Record.IntegerData(2)
      If (Record.IntegerData(2) And msidbCustomActionTypeInScript) <> 0 Then
         'WScript.Echo "Here 1, Type=" & Record.IntegerData(2)
         Record.IntegerData(2) = Record.IntegerData(2) Or msidbCustomActionTypeNoImpersonate
         'WScript.Echo "Here 2, Type=" & Record.IntegerData(2)
         View.Modify msiViewModifyReplace, Record : CheckError
      End If
   Loop
   View.Close
End Sub

Sub Proc2()
   '' 2. problem: explicit format User-Errors, otherwise they are not visible in Vista, the User just sees Error 2869
   sql = "INSERT INTO `Error` (`Error`, `Message`) VALUES (1001, 'Error [1]: [2]')"
   Set View = database.OpenView(sql) : CheckError
   WScript.Echo "Here 2"
   View.Execute : CheckError
   WScript.Echo "Here 3"
   View.Close
End Sub

Sub CheckError
   Dim message, errRec
   If Err = 0 Then Exit Sub
   message = Err.Source & " " & Hex(Err) & ": " & Err.Description
   If Not installer Is Nothing Then
      Set errRec = installer.LastErrorRecord
      If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
   End If
   Fail message
End Sub

Sub Fail(message)
   Wscript.Echo message
   Wscript.Quit 2
End Sub
'------------------------------------------------

沒有留言: