Dealing with Non-English characters in VBScript

I wrote a VBScript to deal with file and folders in a given path. I am going to explain the issue related to "Non-English" characters in file name and how I resolved.

Filename or contents have NON-English (Unicode) characters. VBScript functions like "OpenTextFile", "WriteLn" and "ReadLn" are encountering below error.

Microsoft VBScript runtime error: Invalid procedure call or argument

After some research, I found out it’s the Unicode formatted files are the issue. By default, VBScript’s "file system object" handles only ASCII formatted file names. The OpenTextFile function has the following format from the Help,

object.OpenTextFile(filename[, iomode[, create[, format]]])

Note the "Format" parameter (the last one) which holds the answer for dealing with Unicode files. The "format" is explained in help file as below,

format : Optional. One of three Tristate values used to indicate the format of the opened file. If omitted, the file is opened as ASCII

The format argument can have any of the following settings:






Opens the file using the system default.



Opens the file as Unicode.



Opens the file as ASCII.

Using TristateTrue (-1) in OpenTextFile function fixed "Non-Engilsih" character problem.


fso.OpenTextFile "Non-English FileName.doc", ForReading, TristateTrue


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s