Tuesday, November 29, 2005

VBScript Editing in Visual Studio

After much frustration with Notepad I have worked out this solution. It provides color coding of VBScript commands but not IntelliSense for the Wscript object. (need the equivalent of references in VB)When you open a .vbs file in Visual InterDev it is treated as a text file. To force VI to use the HTML editor (used for ASP and client side code color editing) you must make some changes to the registry. First delete the value 'vbs' from this key (if it exists)


and add a new DWORD value called 'vbs' with hex value 28 to this key


Now to create an option for creating a new vbs file in the 'File', 'New File' menu, edit the file

{$Install_Drive}\Program Files\Microsoft Visual Studio\VIntDev98\Templates\NewFileItems\NewFileItems.vsdir

and add a new line at the end of the file (it is a long line that may wrap over several lines)

New vbs File.vbs|{164B10B9-B200-11D0-8C61-00A0C91E29D5}|VBS File|60|Create a new vbs file and add open it in the editor|c:\WINDOWS\Wscript.exe|3| |VBS File

Confirm the path to Wscript.exe which is used to get the icon to display in the dialog box. You MUST add an additional CRLF at the end of this file otherwise VI will hang (there is one blank line for each entry). Now create a file in the same directory called New vbs File.vbs with the following lines...

'<% This line will turn on the color coding' add any standard commands you want to make this a template vbs fileSet WshShell = WScript.CreateObject("WScript.Shell")Set oFS = WScript.CreateObject(Scripting.FileSystemObject)