我是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) –