If you are programming with Visual Basic Script, you have difficulties to find a bug in your script: there isn't any debugger for VBS! This tip shows how you can easily use Visual Studio for this.
Normally, you start a script from the command line like this:
In order to debug your script you only need to add the parameter
cscript.exe /x myScript.vbs
This will set a breakpoint and throw an immediate exception, which starts the debugger immediately after the script starts running.
The following dialog will be shown where you can choose Visual Studio and step into your VBS code:
Not all versions of Visual Studio support Just-In-Time debugging, especially the VS Express Editions are the problem. You recognize whether your version supports the JIT debugging as follows:
Visual Studio -> Tools -> Options -> Debugging -> Just-In-Time
A good news: the new Visual Studio 2019 (even the Community Edition) do support the VBS debugging!
Useful Links and Information
- Creating And Using Scripts - http://wsh2.uw.hu/ch01d.html#20
- How To Debug WSH, VBScript And JScript