About Windows Installer, the .NET Framework, and Visual Studio.
Yesterday I blogged about what a patch file (.msp file) contains, as well as most other Windows Installer files. You might find, however, that some of the sample Windows Installer scripts in the Samples\SysMgmt\Msi\Scripts don't work with patch files. The reason is because you must pass msiOpenDatabaseModePatchFile (32) to the Installer.OpenDatabase automation method. This corresponds to passing MSIDBOPEN_PATCHFILE to the MsiOpenDatabase function.
Two scripts in particular that are helpful for enumerating streams and storages in a package are WiStream.vbs and WiSubStg.vbs, and the necessary change to conditionally pass msiOpenDatabaseModePatchFile is a simple change, as shown below for WiStream.vbs:
13a14> Const msiOpenDatabaseModePatchFile = 3250a52> Dim patchMode : If LCase(GetExtension(databasePath)) = ".msp" Then patchMode = msiOpenDatabaseModePatchFile Else patchMode = 063c65< Dim database : Set database = installer.OpenDatabase(databasePath, openMode) : CheckError---> Dim database : Set database = installer.OpenDatabase(databasePath, openMode + patchMode) : CheckError104a107,116> > Function GetExtension(path)> Dim dot : dot = InStrRev(path, ".")> Dim bslash : bslash = InStrRev(path, "\")> If dot > bslash Then> GetExtension = Mid(path, dot)> Else> GetExtension = Empty> End If> End Function
You can download a ZIP archive of diff-style patch files for both scripts (like the example above), or you can download and install a small patch for the most recent Platform SDK. This patch is not supported by Microsoft, but if you have any problems please let me know. It simply updates the two aforementioned script files and you can remove it at any time from the Add/Remove Programs (ARP) control panel.
Update: Install the MSP by extracting it from the ZIP archive, then open a command window and type the following command:
msiexec.exe /p "[path to msp]Scripts.msp" /qb+
Hi there Heath,
Just to let you know that your links are dead. Else you're doing a great job, thank you very much for your great work :)
@NickL, thanks. Unfortunately, the WinISP site went down a long time back and I don't think I saved anything from it (forgot this was there). However, I wrote a bunch of PowerShell cmdlets at http://psmsi.codeplex.com that do this and more, and a major iteration is uploading soon (2.2) with about double the functionality. What's nice about this is that you can compose the various cmdlets in different ways to get different results, making this whole experience more robust. I also have samples up there on the site and will be adding more documentation soon (before 2.2 goes live - probably in a week or two).