簡體   English   中英

VBS運行時錯誤代碼800A01B6

[英]VBS Runtime error code 800A01B6

我是VBS腳本的新手。 我在以下腳本中的第54行第5個字符上遇到了錯誤。 該錯誤顯示“對象不支持此屬性或方法:'MimeMapArray'”。

它所指的行是:MimeMapArray(i)= CreateObject(“ MimeMap”)

你能告訴我我做錯了嗎? 這是完整的腳本。 注意,我試圖通過雙擊此VBS文件在XP OS上運行此文件。

' 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."

' AddMimeType Sub
Sub AddMimeType(ByVal Ext, ByVal MType)

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

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

End Sub

我可以建議的第一件事是使用cscript執行。 您可以通過消息框獲得更多不會消失的信息。

  1. 打開命令提示符(開始,運行,鍵入CMD)。
  2. 轉到腳本所在的位置,然后鍵入以下內容:

cscript scriptname.vbs

...其中scriptname.vbs是腳本的名稱。

其次,您似乎缺少createobject行前面的“集合”。 在這里看看以供參考。

該行應如下所示:

set MimeMapArray(i) = CreateObject("MimeMap")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM