Ошибка компиляции microsoft vbscript код 800a0408

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 = "\testpublicusers" & strUserName & ""
strRemotePath2 = "\testpublicgroups"
strRemotePath3 = "\testscans"


'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

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

Code  Error 800A0408 – Invalid Character

Troubleshooting Code 800A0408 – Invalid Character

Introduction to Code 800A0408

This error code, 800A0408 occurs when you execute a VBScript.  A wild guess a problem with an apostrophe, possibly in a ‘REM statement.Code  Error 800A0408 - Invalid Character

The Symptoms You Get

The script does not execute as you had hoped. Instead you get a WSH message box like this picture:

The Cause of error 800A0408

Your VBScript contains an illegal character, often at the beginning of a line.  It can happen if you copy the script from word, then paste into notepad.  For example, to ‘Rem out a line we need the apostrophe, which is ASCII character 39; however if you paste from word you may get ASCII 96 (Grave accent).

Note the clue Source: Microsoft VBScript compilation error, this means a syntax error in your script.

The Solutions

Check the punctuation marks in your VBScript, particularly look out for apostrophes and commas that do not display correctly.  The reference to Line: 1 Char 1, means that the very first symbol that is probably wrong.

  ‡

Example 1 of error code 800A0408 – Invalid Character

Note: The error  Rem VBScript

It should be ‘ Rem VBScript

  Rem VBScript
Set WshShell = WScript.CreateObject(«WScript.Shell»)
Set WshNetwork = WScript.CreateObject(«WScript.Network»)
Set AllDrives = WshNetwork.EnumNetworkDrives()

DriveLetter = «N:» ‘must be capitalized
RemotePath = «\alanhome»

AlreadyConnected = False
For i = 0 To AllDrives.Count – 1 Step 2
If AllDrives.Item(i) = DriveLetter Then AlreadyConnected = True
Next

If AlreadyConnected = False then
WShNetwork.MapNetworkDrive DriveLetter, RemotePath
WshShell.PopUp «Drive » & DriveLetter & » connected successfully.»

Else
WShNetwork.RemoveNetworkDrive DriveLetter
WshShell.PopUp «Drive » & DriveLetter & » disconnected.»
End if

»

Example 2 Code 800A0408 – Invalid Character

I include this screen shot just to emphasise that Char: number need not be one.  Thus Char: 20, or what ever your char number is, becomes a big clue in tracing obscure characters that may have sneaked into your script.

Code 800A0408 - Invalid Character

See More Windows Update Error Codes 8004 Series

• Error 800A101A8 Object Required   •Error 800A0046   •Error 800A10AD   •Error 800A000D

• Error 80048820   •Error 800A0401   •Review of SolarWinds Permissions Monitor

• Error 80040E14   • Error 800A03EA   • Error 800A0408   • Error 800A03EE

Solarwinds Free WMI MonitorGuy Recommends: WMI Monitor and It’s Free!

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, SolarWinds have created the WMI Monitor so that you can examine these gems of performance information for free.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor


Do you need additional help?

  • For interpreting the WSH messages check Diagnose 800 errors.
  • For general advice try my 7 Troubleshooting techniques.
  • See master list of 0800 errors.
  • Codes beginning 08004…
  • Codes beginning 08005…
  • Codes beginning 08007…
  • Codes beginning 0800A…

Give something back?

Would you like to help others?  If you have a good example of this error, then please email me, I will publish it with a credit to you:

If you like this page then please share it with your friends


About The Author

Guy Thomas

Troubleshooting Code 800A0408 – Invalid Character

Introduction to Code 800A0408

This error code, 800A0408 occurs when you execute a VBScript.  A wild guess a problem with an apostrophe, possibly in a ‘REM statement.Code Error 800A0408 - Invalid Character

The Symptoms You Get

The script does not execute as you had hoped. Instead you get a WSH message box like this picture:

The Cause of error 800A0408

Your VBScript contains an illegal character, often at the beginning of a line.  It can happen if you copy the script from word, then paste into notepad.  For example, to ‘Rem out a line we need the apostrophe, which is ASCII character 39; however if you paste from word you may get ASCII 96 (Grave accent).

Note the clue Source: Microsoft VBScript compilation error, this means a syntax error in your script.

The Solutions

Check the punctuation marks in your VBScript, particularly look out for apostrophes and commas that do not display correctly.  The reference to Line: 1 Char 1, means that the very first symbol that is probably wrong.

  ‡

Example 1 of error code 800A0408 – Invalid Character

Note: The error  Rem VBScript

It should be ‘ Rem VBScript

  Rem VBScript
Set WshShell = WScript.CreateObject(«WScript.Shell»)
Set WshNetwork = WScript.CreateObject(«WScript.Network»)
Set AllDrives = WshNetwork.EnumNetworkDrives()

DriveLetter = «N:» ‘must be capitalized
RemotePath = «alanhome»

AlreadyConnected = False
For i = 0 To AllDrives.Count – 1 Step 2
If AllDrives.Item(i) = DriveLetter Then AlreadyConnected = True
Next

If AlreadyConnected = False then
WShNetwork.MapNetworkDrive DriveLetter, RemotePath
WshShell.PopUp «Drive » & DriveLetter & » connected successfully.»

Else
WShNetwork.RemoveNetworkDrive DriveLetter
WshShell.PopUp «Drive » & DriveLetter & » disconnected.»
End if

»

Example 2 Code 800A0408 – Invalid Character

I include this screen shot just to emphasise that Char: number need not be one.  Thus Char: 20, or what ever your char number is, becomes a big clue in tracing obscure characters that may have sneaked into your script.

Code 800A0408 - Invalid Character

See More Windows Update Error Codes 8004 Series

• Error 800A101A8 Object Required   •Error 800A0046   •Error 800A10AD   •Error 800A000D

• Error 80048820   •Error 800A0401   •Review of SolarWinds Permissions Monitor

• Error 80040E14   • Error 800A03EA   • Error 800A0408   • Error 800A03EE

Solarwinds Free WMI MonitorGuy Recommends: WMI Monitor and It’s Free!

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, SolarWinds have created the WMI Monitor so that you can examine these gems of performance information for free.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor


Do you need additional help?

  • For interpreting the WSH messages check Diagnose 800 errors.
  • For general advice try my 7 Troubleshooting techniques.
  • See master list of 0800 errors.
  • Codes beginning 08004…
  • Codes beginning 08005…
  • Codes beginning 08007…
  • Codes beginning 0800A…

Give something back?

Would you like to help others?  If you have a good example of this error, then please email me, I will publish it with a credit to you:

If you like this page then please share it with your friends


  • Remove From My Forums
  • Question

  • Hello, reviving an old one on this forum: http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/special-characters-in-vbscript-strings/ and
    also as posted on: http://itknowledgeexchange.techtarget.com/itanswers/escaping-special-characters-in-run-with-administrator-privileges-script/

    I used this script:

    Here is a VB Script Vall Script that will get around the Password Prompt when «RunAs» is called…

    ‘Start

    ‘————————————————————————————

    ‘ To Run other VB Scripts or even Batch Files with Admin Priviliges’

    ‘———————————————————————————-

    Dim WshShell, objFSO

    suser
    = «YourAdminAccount@YourDomain.com»

    sPass = «YourPassWord»

    ‘——————————————————————————————————————————————————————————————

    ‘Put your Domain Account and Password in between the qoutes, REMEMBER! the Password will be clear text. If this is a standalone just take off the @YourDomain.com

    ‘——————————————————————————————————————————————————————————————

    sCommand = «wscript \UNCServerNameShareFolderYourScript.vbs»

    ‘—————————————————————————————————————————————————————————————————————

    ‘This will be the path were the scripted you want called will be at. Please note you can substitute the ablove for a local directory (Example: C:FolderYourScript.vbs)

    ‘————————————————————————————————————————————————————————————————————-

    Set objComputer = CreateObject(«Shell.LocalMachine»)

    Set WshNetwork = CreateObject(«WScript.Network»)

    Set WshShell = CreatObject(«WScript.Shell»)

    Set WshEnv = wshShell.Environment(«Process»)

    WinPath = WshEnv(«SystemRoot»)&»System32runas.exe»

    rc = WshShell.Run («runas /noprofile /user:» & suser & » » $ Chr(34) & sCommand & Chr(34))

    WScript.Sleep 900

    WshShell. AppActivate(WinPath)

    WScript.quit

    ‘End

Answers


  • suser = «YourAdminAccount@YourDomain.com»
    sPass = «YourPassWord»

    rc = WshShell.Run («runas /noprofile /user:» & suser & » » $ Chr(34) & sCommand & Chr(34))
    WScript.Sleep 900
    WshShell. AppActivate(WinPath)

    This is definitely ill-advised. There is a reason the runas program does not accept a password on its command line. To quote

    Raymond Chen:

    The RunAs program demands that you type the password manually. Why doesn’t it accept a password on the command line?

    This was a conscious decision. If it were possible to pass the password on the command line, people would start embedding passwords into batch files and logon scripts, which is laughably insecure.

    In other words, the feature is missing to remove the temptation to use the feature insecurely.

    In other words, you should not do this.

    Bill

    • Proposed as answer by

      Wednesday, May 2, 2012 6:16 PM

    • Marked as answer by
      IamMred
      Sunday, May 6, 2012 11:59 PM

RRS feed

  • Remove From My Forums
  • Question

  • when i start my computer i get this error message Microsoft VBScript compilation error. Code 800A0408

All replies

  • Can you be more specific? ‘When I start my computer’ — does this message appear when the pc boots up? At what point does it appear?

    If this is literally when the computer boots it’s not an EW issue.

    Ian
    MS MVP Expression

    http://www.ew-resource.co.uk
    http://www.fp-resource.co.uk


    Ian Haynes

  • when the computer boots and any time i click on task manager.

  • when the computer boots and anytime i click on the task manager.
    thank you.

  • Sounds to me like you might have a startup script that’s doing this. Simply starting Task Manager won’t invoke any VBScript. Will this error occur if you just log in and don’t do anything else? Does it give you a file name? That error code means that there was an invalid character in a VBScript (.vbs more than likely) file.

    Jim Cheshire
    Jimco Software and Books
    http://www.jimcosoftware.com
    http://www.jimcobooks.com

    Author of:
    Microsoft Expression Web 3 In Depth
    Special Edition Using Microsoft Expression Web 2
    The Microsoft Expression Web Developer’s Guide to ASP.NET 3.5
    Special Edition Using Microsoft Expression Web

    My Expression Web 3 blog on Network World:
    http://www.networkworld.com/community/blog/10560

  • This error occur anytime i log in and don’t do anything else. The file name is C:WINDOWSsystem32winjpg.jpg

  • Sounds like you might have a virus.

    http://www.sophos.com/security/analyses/viruses-and-spyware/w32autorunalb.html

    Jim Cheshire
    Jimco Software and Books
    http://www.jimcosoftware.com
    http://www.jimcobooks.com

    Author of:
    Microsoft Expression Web 3 In Depth
    Special Edition Using Microsoft Expression Web 2
    The Microsoft Expression Web Developer’s Guide to ASP.NET 3.5
    Special Edition Using Microsoft Expression Web

    My Expression Web 3 blog on Network World:
    http://www.networkworld.com/community/blog/10560

  • Since this is a Windows not an Expression Web problem I would suggest that you ask in a Windows group or if Jim is correct in one of the anti-virus forums. In any event this is not the place to resolve your Windows boot issue.


    MS MVP Expression Tutorials & Help http://by-expression.com and online instructor led
    Expression Classes

Возможно, вам также будет интересно:

  • Ошибка компиляции microsoft vbscript 800a0400 предполагается наличие инструкции
  • Ошибка команды нет android что делать
  • Ошибка компиляции microsoft jscript условная компиляция выключена
  • Ошибка команды на открытие сеанса
  • Ошибка компиляции microsoft jscript предполагается наличие

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии