Creating a VBScript file Within a VSAE Project

Not sure if this issue has been blogged before. Yesterday, while I was working on a management pack project, I noticed that if I created a new VBScript file within VSAE (In Visual Studio), the script will not run when I test it in command prompt.

To replicate this issue again, I firstly created a brand new VBScript file inside the project:


Then added one line to the script and saved it:


Now, when tried to run it via the command prompt, I got a error saying there’s an invalid character at position (1,1) – which is the beginning of the script:


This error normally means the encoding for the .vbs file is not set as ANSI, which is exactly the problem in this case. When I opened the VBScript using NotePad++, looks like the script is encoded in UTF-8


To fix this issue, I simply changed the encoding to ANSI and saved the VBScript


Now it runs perfectly:


However, once the VBScript gets updated and saved again within Visual Studio, the encoding will revert back to UTF-8.

I don’t think this issue impacts the finishing piece of the management pack, but will impact developers when testing the script while still writing the MP. The alternative is to create the blank file outside of the Visual Studio and import it in by adding an existing item. I noticed if the file was initially created outside of Visual Studio and later got updated in Visual Studio, the encoding remains as ANSI.

Because of this reason, from now on, I’ll always create the VBScript file outside of Visual Studio when using VSAE.


  1. I’ve had the same problem.
    In Visual Studio you have an option to save file without BOM: Save As… -> Save with Encoding -> Unicode (UTF-8 without signature)


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: