VBS无效字符

时间:2010-03-09 20:42:25

标签: iis-6 windows-xp vbscript

这是一个简单的VBS脚本。但是当我双击它时,我在第1行,字符1上得到无效字符800A0408,我认为这是第一个“昏暗”。我是VBS的新手 - 你能告诉我我做错了什么吗?仅供参考,我安装了XP操作系统和IIS6管理器。

' 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

3 个答案:

答案 0 :(得分:2)

引用http://classicasp.aspfaq.com/general/why-do-i-get-800a0408-errors.html

  

如果您剪切并粘贴其他代码   来源(例如网站,其他   编辑等,你经常带来   不显示的字符   记事本,但仍然存在    - 或者看起来像不可打印的字符,看起来很小   广场。如果你正在看线   有问题,它不仅仅是一个   未封闭的字符串或过早的   回车,尝试删除   完全排队并重新输入   用手。这应该消除   “看不见”问题的可能性   捣乱溪流的人物。

答案 1 :(得分:2)

如果使用vim打开文件并使用ex命令'set list',它将显示可能导致此问题的任何不可见字符。

答案 2 :(得分:0)

保存文件时检查编码,在NotePad中必须是ANSI