mirror of
https://github.com/timsutton/brigadier.git
synced 2025-05-22 03:05:26 -04:00
MSI NOCHECK transform sample
This commit is contained in:
parent
126b52a41f
commit
57a31ff1f5
3 changed files with 71 additions and 0 deletions
13
msi-transform/README.md
Normal file
13
msi-transform/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
## Modifying MSI properties
|
||||
|
||||
### Setting NOCHECK for non-Mac models
|
||||
|
||||
If you'd like to test a Boot Camp installation in a VM, a Boot Camp installer won't work out of the box, because one of its checks is to make sure the host is an appropriate Mac hardware model. However, this condition can be bypassed by setting a debug MSI property, `NOCHECK`, to 1. Components like graphics drivers still won't try to install, but at least the basic Boot Camp Services and several drivers will. It may be possible to force other components by setting other properties, but this should at least simulate a very basic install.
|
||||
|
||||
It's possible (with some difficulty) to obtain the Orca MSI-editing tool from Microsoft to modify the MSI database. However, these database modifications can also be saved to "transform" files and applied using other tools.
|
||||
|
||||
Included in this directory is a VBS script, `WiUseXfm.vbs`, copied from the [Windows Installer SDK scripting examples]("http://msdn.microsoft.com/en-ca/library/windows/desktop/aa372865(v=vs.85).aspx"). The `set_nocheck.mst` file is a pre-made transform that only modifies this `NOCHECK` property. This allows you to quickly modify the installer before calling `msiexec`. Here's how you could call this from within this folder:
|
||||
|
||||
`cscript WiUseXfm.vbs \path\to\Drivers\Apple\BootCamp.msi set_nocheck.mst`
|
||||
|
||||
Depending on its general usefulness for testing, this functionality will probably be rolled into brigadier as a command-line option.
|
58
msi-transform/WiUseXfm.vbs
Executable file
58
msi-transform/WiUseXfm.vbs
Executable file
|
@ -0,0 +1,58 @@
|
|||
' Windows Installer utility to applay a transform to an installer database
|
||||
' For use with Windows Scripting Host, CScript.exe or WScript.exe
|
||||
' Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
' Demonstrates use of Database.ApplyTransform and MsiDatabaseApplyTransform
|
||||
'
|
||||
Option Explicit
|
||||
|
||||
' Error conditions that may be suppressed when applying transforms
|
||||
Const msiTransformErrorAddExistingRow = 1 'Adding a row that already exists.
|
||||
Const msiTransformErrorDeleteNonExistingRow = 2 'Deleting a row that doesn't exist.
|
||||
Const msiTransformErrorAddExistingTable = 4 'Adding a table that already exists.
|
||||
Const msiTransformErrorDeleteNonExistingTable = 8 'Deleting a table that doesn't exist.
|
||||
Const msiTransformErrorUpdateNonExistingRow = 16 'Updating a row that doesn't exist.
|
||||
Const msiTransformErrorChangeCodePage = 256 'Transform and database code pages do not match
|
||||
|
||||
Const msiOpenDatabaseModeReadOnly = 0
|
||||
Const msiOpenDatabaseModeTransact = 1
|
||||
Const msiOpenDatabaseModeCreate = 3
|
||||
|
||||
If (Wscript.Arguments.Count < 2) Then
|
||||
Wscript.Echo "Windows Installer database tranform application utility" &_
|
||||
vbNewLine & " 1st argument is the path to an installer database" &_
|
||||
vbNewLine & " 2nd argument is the path to the transform file to apply" &_
|
||||
vbNewLine & " 3rd argument is optional set of error conditions to suppress:" &_
|
||||
vbNewLine & " 1 = adding a row that already exists" &_
|
||||
vbNewLine & " 2 = deleting a row that doesn't exist" &_
|
||||
vbNewLine & " 4 = adding a table that already exists" &_
|
||||
vbNewLine & " 8 = deleting a table that doesn't exist" &_
|
||||
vbNewLine & " 16 = updating a row that doesn't exist" &_
|
||||
vbNewLine & " 256 = mismatch of database and transform codepages" &_
|
||||
vbNewLine &_
|
||||
vbNewLine & "Copyright (C) Microsoft Corporation. All rights reserved."
|
||||
Wscript.Quit 1
|
||||
End If
|
||||
|
||||
' Connect to Windows Installer object
|
||||
On Error Resume Next
|
||||
Dim installer : Set installer = Nothing
|
||||
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
|
||||
|
||||
' Open database and apply transform
|
||||
Dim database : Set database = installer.OpenDatabase(Wscript.Arguments(0), msiOpenDatabaseModeTransact) : CheckError
|
||||
Dim errorConditions:errorConditions = 0
|
||||
If Wscript.Arguments.Count >= 3 Then errorConditions = CLng(Wscript.Arguments(2))
|
||||
Database.ApplyTransform Wscript.Arguments(1), errorConditions : CheckError
|
||||
Database.Commit : CheckError
|
||||
|
||||
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 & vbNewLine & errRec.FormatText
|
||||
End If
|
||||
Wscript.Echo message
|
||||
Wscript.Quit 2
|
||||
End Sub
|
BIN
msi-transform/set_nocheck.mst
Executable file
BIN
msi-transform/set_nocheck.mst
Executable file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue