Installing MSXML4 via MSXML4.CAB

13 Aug 2002 17:47

Introduction

MSXML4 can be installed on client computers in two ways:  via an MSI (Microsoft Installer) file as a "merge module," or via a CAB (cabinet archive) file.

MSI 2.0 is not recommended.  Many Windows 95, 98, NT, and 2000 computers do not have Microsoft Installer 2.0 installed.  Windows XP comes with Microsoft Installer 2.0 already installed.

Installing Microsoft Installer 2.0 is extremely dangerous.  Installing Microsoft Installer 2.0 on a machine with Terminal Services installed in application server mode can result in serious unrecoverable damage to the computer (meaning a reinstall of the operating system may be required).

Therefore, it is desirable to either build MSI 1.x installers or avoid MSI altogether.  If you don't use MSI, you can install MSXML4 via the MSXML4 CAB (cabinet) file.


Credits

Many thanks to Ning Xie for providing this awesome installer script.


Installing MSXML4 via the Web

Installing a CAB file via the Internet is trivial. 

  1. Extract the CAB file from MSDN
  2. Install msxml4.cab on your web server
  3. Create a web page containing the following object tag:

<OBJECT style='visibility:hidden'
CLASSID='CLSID:88d969c0-f192-11d4-a65f-0040963251e5'
CODEBASE='msxml4.cab'></OBJECT>


Installing MSXML4 via non-MSI Technology

Let's say you've written a Win32 application that requires MSXML4.  Your application is installed via installation technology that doesn't require MSI (if you were using MSI you could just use the convenient MSXML4 merge module, which would be trivial).

The following solution requires IE4 or later.  It does not require an active Internet connection.

  1. Extract the CAB file from MSDN
  2. Include msxml4.cab in your installation program
  3. Save the script below as installMSXML4.vbs
  4. Include installMSXML4.vbs in your installation program
  5. In your installation program, run installMSXML4.vbs with the following parameters:
    1. The name of your application {put inside double-quotes}
    2. The UNC path of the msxml4.cab file that was copied to the local file system by your installation program
      • It's easiest if you can tell the installation program to change the directory to the path of msxml4.cab and simply pass in "msxml4.cab" (see below for a downloadable example)
      • Otherwise the path must be in the format of \\machinename\driveletter$\path\msxml4.cab, e.g., "\\davis\c$\program files\company\msxml4.cab"

If MSXML4 is already installed, nothing will appear.  If MSXML4 is not installed, something like the following will appear:

For testing, you can "trick" IE into reinstalling MSXML4 by:

  1. Run the registry editor (regedit.exe)
  2. Select HKEY_CLASSES_ROOT
  3. Search for the key 88d969c0-f192-11d4-a65f-0040963251e5
  4. Delete the key

Note that will not work if another application has MSXML4.DLL loaded in memory.  In this case you may need to reboot.


Download an Example

Download a similar script and MSXML4.CAB here

This archive also contains installmsxml4.exe which accepts two parameters:

  1. Your application's name (can be anything) {put inside double-quotes}
  2. The full path of the folder containing MSXML4.CAB {put inside double-quotes}
    This parameter should not contain the text "msxml4.cab"

This application changes the current directory and runs the script.


Function SetupCab (sTitle, sID, sPath)

set WshShell = WScript.CreateObject("WScript.Shell")
set oIE = CreateObject("InternetExplorer.Application")
On Error Resume Next
With oIE
  .FullScreen = True : .ToolBar = False 
  .RegisterAsDropTarget = False : .Navigate("about:cab_setup")

  do until .readyState = 4 : WScript.Sleep 500 : loop

  With .document
    .ParentWindow.resizeto 440,180
    .ParentWindow.moveto .ParentWindow.screen.width/2-200, _
    .ParentWindow.screen.height/2-90

    .Write("<html><head><style type='text/css'>.primary " _
      & "{font-family:verdana; font-size:10px;} .header " _
      & "{font-family:verdana; font-size:14px;}" _
      & "</style><title>MSXML4 Setup</title><script>bboxwait=true;function " _
      & "closeWindow(){bboxWait=false;}</script></head>" _
      & "<body bgColor=#669966 scroll=no><center><b>" _
      & "<font color=#ffffcc class='header'>" & sTitle & "<BR><BR></font>" _
      & "<font color=#ffffcc class='primary'>" _
      & "Installing Microsoft XML Parser<BR><BR>" _
      & "Please click the Yes button in the<BR>Security Warning window.<BR><BR>" _
      & "This window will close after installation is complete<BR><BR>" _
      & "Please Wait..." _
      & "</font></b>" _
      & "<OBJECT ID='CabControl' style='visibility:hidden' CLASSID='CLSID:"&sID&"' " _
      & "CODEBASE='file://"&sPath&"'></OBJECT>" _ 
      & "<BR><BR><button style='background-color:#669966;' class='primary' " _
      & "onclick='closeWindow();'>" _
      & "<font color=#ffffcc><b>Close Window</b></font></button><BR>" _
      & "</center></body></html>")

    .ParentWindow.document.body.style.borderStyle = "outset"
    .ParentWindow.document.body.style.borderWidth = "3px"

    WshShell.AppActivate("about:cab_setup")

    Do until (.ParentWindow.document.all.CabControl.readyState= 4 or _
             .parentWindow.bboxWait=false )
      oIE.Visible = True : if Err Then Exit Do : WScript.Sleep 500
    Loop
  End With ' document

  .Visible = False
  .Quit
End With ' oIE

WScript.Sleep 500

End Function

SetupCab WScript.Arguments(0), "88d969c0-f192-11d4-a65f-0040963251e5", _
  WScript.Arguments(1)