web-dev-qa-db-ja.com

VBScriptの無効な文字800A0408コンパイルエラー

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

問題はLine 1 Char 1にあると述べています。

22
Mike

考えられる問題は、ファイルのエンコード方法です。 ANSIとして保存して、もう一度実行してください。

63
Rubens Farias

これを修正するために、将来同じ問題を抱えている人のための参考までに:

  1. メモ帳で.vbsを開きます
  2. ファイルに移動して「名前を付けて保存」
  3. ファイル名ボックスのすぐ下に、エンコーディングのドロップダウンメニューが表示されます。 [〜#〜] ansi [〜#〜]を選択します。
21
Ammar

変数名にáéíóúñのような拡張文字を使用していないことを確認してください

0
Pedro Hoton