Checking VBScript syntax

Scott Marlowe picture Scott Marlowe · Aug 18, 2009 · Viewed 24.9k times · Source

Any good utilities out there for verifying VBScript syntax without actually running the script?

What I'm getting at is if I do something like:

If (year == "2005" && type == 1) Then
...
End If

Is there a tool that will tell me that the '&&' really should be 'And' and the '==', just '='?

Answer

intDattashame picture intDattashame · Mar 17, 2012

If you don't want to run your script because you don't want it to actually do anything, then one method I've used is to put in a "WScript.Quit" statement at the beginning of the script (after the Option Explicit if there is one) then run it using cscript.exe or wscript.exe.

For example:

Option Explicit
WScript.Quit
Dim year
If (year == "2005" && type == 1) Then
    WScript.Echo "Hello"
End If

This won't capture undefined variables (like "type" above), but it's an easy, quick way to check you've got the right syntax.