VBS无效字符
问题描述:
这是一个简单的VBS脚本。但是当我双击这个时,我得到第一行的无效字符800A0408,字符1,我认为它是第一个“Dim”。我是VBS新手 - 你能告诉我我做错了什么吗?仅供参考,我安装了XP操作系统和IIS6管理器。VBS无效字符
' 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.
Dim MimeMapObj
Dim MimeMapArray
Dim WshShell
Dim oExec
Const ADS_PROPERTY_UPDATE = 2
' Set the MIME types to be added
Dim 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
答
如果使用vim打开文件并使用ex命令'set list',它会显示任何可能导致此问题的不可见字符。
答
报价http://classicasp.aspfaq.com/general/why-do-i-get-800a0408-errors.html
如果你从其它的 来源(如网站,其他 编辑器等),粘贴代码,你经常一起 角色带来不中 露面记事本,但是,目前 - 或确实显示为不可打印的字符,看起来像很小的 正方形。如果您正在查看有问题的行 ,并且它不是简单的 未关闭的字符串或过早的 回车,请尝试删除 行,然后手动重新输入它们 。这应该消除 字符堵塞流的“隐形”问题的可能性。
答
保存文件时检查编码,必须是ANSI记事本
谢谢,是的,我之前读过。但是,我在记事本中查看过这个文件并重新输入了第一行,但我仍然有同样的错误。任何其他想法?语法正确,否?是不是说第一个“昏暗”错误? – salvationishere 2010-03-09 20:51:03