VBScript 无效字符 800A0408 编译错误

VBScript 无效字符 800A0408 编译错误

问题描述:

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

I get a compilation error when I try to run the following vbs code from a command prompt in Windows 7.

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

它说问题出在 Line 1 Char 1 上.有什么想法吗?

It says the issue is with Line 1 Char 1. Any ideas?

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

A possible problem is how your file was encoded; try to save it as ANSI and run it again.