How to Debug Local VBS (VBScript) files and JS files
It is well known that VBScript (and JavaScript) can be used in ASP pages for Web Applications, and it is also known that vbs files (and js files) can run locally under WSH (Windows Script Hosting) in Microsoft Windows environment. The command line to run vbs, say foo.vbs, locally is:
WScript.exe foo.vbs
You can just doubleclick foo.vbs in Windows Explorer to run it too. WScript.exe runs foo.vbs under Windows Graphical Environment. In many IT tasks, we prefer command line (DOS) interface, so we put vbs in batch files. For command line execution, where the input and output are to and from DOS box, we type:
CScript.exe foo.vbs.
To create/edit vbs (and js), we can just use a simple editor, like Notepad, or your preferred editor. To debug, we either put the whole file into VB6 development environment, modify some lines to be suitable for VB6 syntax, and debug there. Once debugged, we change the syntax back to VBScript and use it in production. If we can’t afford to buy VB6, we can just use "MsgBox" ("printf") way. NO matter we are using VB6 or MsgBox approach, the debug process is not productive at all.
Microsoft does provide the debugging environment for vbs and js file, but the way to invoke it is a kind of tricky. To debug foo.vbs, the command line is:
WScript.exe //D //X foo.vbs
Right after you type this, the system tells you a run-time exception happened, do you want to debug ? You say Yes.
If you have Visual Studio Visual Interdev installed, the system will invoke the Visual Interdev debugger, mdm.exe, for you. This is preferred, as the function is rich, and the UI is exactly like debugging under ASP environment.
If you do not have Visual Studio Visual Interdev installed, the system will check if you have Microsoft Script Debugger installed. If yes, it will invoke this debugger MSScrDBG.exe. This debug is less convenient than the previous one, and the debug command set are different from the Visual Interdev one.
If you don’t have Microsoft Script Debugger installed, you can download it from:
http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en
For more information:
http://support.microsoft.com/default.aspx?scid=kb;en-us;308364

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home