{"id":2913,"date":"2005-09-02T19:40:00","date_gmt":"2005-09-02T19:40:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2005\/09\/02\/updated-sample-msi-scripts\/"},"modified":"2005-09-02T19:40:00","modified_gmt":"2005-09-02T19:40:00","slug":"updated-sample-msi-scripts","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/updated-sample-msi-scripts\/","title":{"rendered":"Updated Sample MSI Scripts"},"content":{"rendered":"<p>Yesterday I <a href=\"http:\/\/blogs.msdn.com\/heaths\/archive\/2005\/09\/01\/459561.aspx\">blogged<\/a> about what a patch file (<i>.msp<\/i> file) contains, as well as most other Windows Installer files. You might find, however, that some of the sample Windows Installer scripts in the <i>Samples\\SysMgmt\\Msi\\Scripts<\/i> don&#8217;t work with patch files. The reason is because you must pass <code>msiOpenDatabaseModePatchFile<\/code> (32) to the <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/installer_opendatabase.asp\"><code>Installer.OpenDatabase<\/code><\/a> automation method. This corresponds to passing <code>MSIDBOPEN_PATCHFILE<\/code> to the <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/msiopendatabase.asp\"><code>MsiOpenDatabase<\/code><\/a> function.<\/p>\n<p>Two scripts in particular that are helpful for enumerating streams and storages in a package are <i>WiStream.vbs<\/i> and <i>WiSubStg.vbs<\/i>, and the necessary change to conditionally pass <code>msiOpenDatabaseModePatchFile<\/code> is a simple change, as shown below for <i>WiStream.vbs<\/i>:<\/p>\n<p><font color=\"#804040\"><b>13a14<\/b><\/font><br \/><font color=\"#008080\">&gt; Const msiOpenDatabaseModePatchFile&nbsp;&nbsp;&nbsp;&nbsp;= 32<\/font><br \/><font color=\"#804040\"><b>50a52<\/b><\/font><br \/><font color=\"#008080\">&gt; Dim patchMode : If LCase(GetExtension(databasePath)) = &#8220;.msp&#8221; Then patchMode = msiOpenDatabaseModePatchFile Else patchMode = 0<\/font><br \/><font color=\"#804040\"><b>63c65<\/b><\/font><br \/><font color=\"#6a5acd\">&lt; Dim database : Set database = installer.OpenDatabase(databasePath, openMode) : CheckError<\/font><br \/><font color=\"#6a5acd\">&#8212;<\/font><br \/><font color=\"#008080\">&gt; Dim database : Set database = installer.OpenDatabase(databasePath, openMode + patchMode) : CheckError<\/font><br \/><font color=\"#804040\"><b>104a107,116<\/b><\/font><br \/><font color=\"#008080\">&gt; <\/font><br \/><font color=\"#008080\">&gt; Function GetExtension(path)<\/font><br \/><font color=\"#008080\">&gt;&nbsp;&nbsp;&nbsp;&nbsp; Dim dot : dot = InStrRev(path, &#8220;.&#8221;)<\/font><br \/><font color=\"#008080\">&gt;&nbsp;&nbsp;&nbsp;&nbsp; Dim bslash : bslash = InStrRev(path, &#8220;\\&#8221;)<\/font><br \/><font color=\"#008080\">&gt;&nbsp;&nbsp;&nbsp;&nbsp; If dot &gt; bslash Then<\/font><br \/><font color=\"#008080\">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetExtension = Mid(path, dot)<\/font><br \/><font color=\"#008080\">&gt;&nbsp;&nbsp;&nbsp;&nbsp; Else<\/font><br \/><font color=\"#008080\">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetExtension = Empty<\/font><br \/><font color=\"#008080\">&gt;&nbsp;&nbsp;&nbsp;&nbsp; End If<\/font><br \/><font color=\"#008080\">&gt; End Function<\/font><\/p>\n<p>You can <a href=\"http:\/\/hstewart.members.winisp.net\/downloads\/Scripts.zip\">download<\/a> a ZIP archive of diff-style patch files for both scripts (like the example above), or you can <a href=\"http:\/\/hstewart.members.winisp.net\/downloads\/Scripts.msp.zip\">download<\/a> and install a small patch for the most recent <a href=\"http:\/\/msdn.microsoft.com\/platformsdk\">Platform SDK<\/a>. 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.<\/p>\n<p><strong>Update:<\/strong> Install the MSP by extracting it from the ZIP archive, then open a command window and type the following command:<\/p>\n<pre>msiexec.exe \/p \"<em>[path to msp]<\/em>Scripts.msp\" \/qb+<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t work with patch files. The reason is because you must pass msiOpenDatabaseModePatchFile (32) to the Installer.OpenDatabase automation method. This corresponds [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[20],"class_list":["post-2913","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-installation"],"acf":[],"blog_post_summary":"<p>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&#8217;t work with patch files. The reason is because you must pass msiOpenDatabaseModePatchFile (32) to the Installer.OpenDatabase automation method. This corresponds [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/2913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=2913"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/2913\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=2913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=2913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=2913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}