Case of the VBS Compilation Error–Invalid Character

Running a VBS script resulted in error Microsoft VBScript compilation error: Invalid character

image

The line of code apparently containing invalid character was:

    Const ForWriting = 2

Opening in a Hex Editor it was revealed the “spaces” before the word const were something else

image

 

Selecting the blank spaces, copying them, pasting into a notepad search/replace didn’t remove them.

Using HexEdit I search/replaced the relevant bytes with 09 (tab)

image

After this some instances of C2 or A0 were on their own still causing the error, these I replaced with 0x20 (space)

image

After this the script ran fine…

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s