我是VBS腳本的新手。謝謝你們的評論!我現在修復了錯誤800A0401,這要感謝您的幫助。但現在我在第13行出現錯誤800A0414,字符1「Object required」,它是指行: Set MimeTypesToAddArray = Array(「。manifest」,「application/manifest」,「.xaml」,_VBS預期結束語句
現在我明白了線條計算是如何工作的,它可以計算註釋行數,但我仍在審查所有建議,但是如果您有任何提示,我該如何解決這個錯誤,現在可以超級了!不同意將類型值放在單獨的行上,因爲我已經看到了很多這樣做的例子。是否有任何VBS專家?0
' 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
Set 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
我敢肯定,U可以。請參閱網站:http://msdn.microsoft.com/en-us/library/ms752346.aspx。 當我試圖將Dim放在單獨的行上時,我在第6行中得到了預期的標識符錯誤,字符爲5。註釋行數被計數。 – salvationishere
@salvationishere:請注意,在該示例中,變量MimeTypesToAddArray正在第6行中定義,然後在第10行中分配了一個值...(並且是,註釋行和空行都計數) – Shog9
當我更新代碼時與我的變化我不再有你報告的錯誤。我確實得到了另一個,但我可以通過從這一行刪除括號修復:MimeMapObj.PutEx(ADS_PROPERTY_UPDATE,「MimeMap」,MimeMapArray) –