I am trying to run a .VBS script from Windows Explorer (IIS Manager 6) and am a novice VBScript programming. I am getting above error when running the following code. What am I doing wrong? I just need to generate the IIS MIME types please!
Error detail: Line 49, char 5;
where line 49:
MimeMapArray = MimeMapObj.GetEx("MimeMap")
Code fixed now. Here is how it should look:
' This script adds the necessary Windows Presentation Foundation 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. ' Set the MIME types to be added Dim MimeMapObj Dim MimeMapArray() Dim WshShell Dim oExec Const ADS_PROPERTY_UPDATE = 2
Dim MimeTypesToAddArray MimeTypesToAddArray = Array(".manifest", "application/manifest", ".xaml", _ "application/xaml+xml", ".application", "application/x-ms-application", _ ".deploy", "application/octet-stream", ".xbap", "application/x-ms-xbap", _ ".xps", "application/vnd.ms-xpsdocument")
' 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 "Windows Presentation Foundation MIME types have been registered."
Dim i ' AddMimeType Sub Sub AddMimeType(ByVal Ext, ByVal MType)
' Get the mappings from the MimeMap property.
' Add a new mapping.
For i = 0 to 14
' 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() Next
End Sub