VBScript无效字符800A0408编译错误

时间:2010-01-10 23:27:38

标签: vbscript

当我尝试在Windows 7中从命令提示符运行以下vbs代码时出现编译错误。

Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strUserName

Set objNetwork = CreateObject("WScript.Network")
strUserName = objNetwork.UserName 

strDriveLetter1 = "H:"
strDriveLetter2 = "P:"
strDriveLetter3 = "S:"
strRemotePath1 = "\\test\public\users\" & strUserName & "\"
strRemotePath2 = "\\test\public\groups\"
strRemotePath3 = "\\test\scans\"


'Section which maps two drives, M: and P: and S:
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3

'Extra code just to add a message box
WScript.Echo "Map drives " & strDriveLetter1 & " & " & strDriveLetter2 & " & " & strDriveLetter3

Wscript.Quit

它说问题是1号线Char 1.任何想法?

3 个答案:

答案 0 :(得分:56)

可能的问题是您的文件是如何编码的;尝试将其另存为ANSI并再次运行。

答案 1 :(得分:19)

对于那些在未来遇到同样问题的人来说,为了解决这个问题:

  1. 在记事本中打开.vbs
  2. 转到文件并“另存为”
  3. 在文件名框下方,您会看到一个用于编码的下拉菜单。选择 ANSI

答案 2 :(得分:0)

检查您是否使用变量名称中的扩展字符<áéíóúñ