Configuring IIS To Support WPF .XBAP Express Applications With The Dec CTP

I recently needed the script to set the MIME types and forgot where it was; figured I'd blog it in case others needed it.  However, this script isn't quite right so I fixed it below. There is a typo, which causes the script to fail.  You need to add a comma to the end of line 11.  And, I added the new .xbap extension instead of the old .wba. Here's the correct script, below:

'This script adds the necessary "Avalon" MIME types to an IIS Server.
'To use this script, just double-click or execute it from a command line.
'Running this script multiple times results in multiple entries in the IIS MimeMap.

  Dim MimeMapObj, MimeMapArray, MimeTypesToAddArray, WshShell, oExec
Const ADS_PROPERTY_UPDATE = 2

'Set the MIME types to be added
MimeTypesToAddArray = Array(".manifest", "application/manifest", _
".xaml", "application/xaml+xml", ".application", "application/x-ms-application", ".deploy", "application/octet-stream", _
".xbap", "application/x-ms-xbap")

'Get the mimemap object
Set MimeMapObj = GetObject("IIS://LocalHost/MimeMap")

'Call AddMimeType for every pair of extension/MIME type
For counter = 0 to UBound(MimeTypesToAddArray) Step 2
AddMimeType MimeTypesToAddArray(counter), MimeTypesToAddArray(counter+1)
Next

'Create a Shell object
Set WshShell = CreateObject("WScript.Shell")

'Stop and Start the IIS Service
Set oExec = WshShell.Exec("net stop w3svc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop

  Set oExec = WshShell.Exec("net start w3svc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop

  Set oExec = Nothing

'Report status to user
WScript.Echo "Avalon MIME types have been registered."

 

'AddMimeType Sub
Sub AddMimeType (Ext, MType)

'Get the mappings from the MimeMap property.
MimeMapArray = MimeMapObj.GetEx("MimeMap")

' Add a new mapping.
i = UBound(MimeMapArray) + 1
Redim Preserve MimeMapArray(i)
Set MimeMapArray(i) = CreateObject("MimeMap")
MimeMapArray(i).Extension = Ext
MimeMapArray(i).MimeType = MType
MimeMapObj.PutEx ADS_PROPERTY_UPDATE, "MimeMap", MimeMapArray
MimeMapObj.SetInfo
End Sub