2010-03-10 105 views
1

我想從Windows資源管理器(IIS管理器6)運行.VBS腳本,並且是一個新手VBScript編程。運行以下代碼時出現以上錯誤。我究竟做錯了什麼?我只需要生成IIS MIME類型!VBS運行時錯誤800A000D - 類型不匹配

錯誤詳細信息:第49行,char 5;
其中線49:現在

MimeMapArray = MimeMapObj.GetEx("MimeMap") 

代碼固定。這是它應該看起來如何:

' 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 

回答

0

沒關係,我想出了這個問題。正確的版本現在顯示。