Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debugging 1

Status
Not open for further replies.

EBGreen

Programmer
Apr 1, 2004
2,867
US
Is there a JIT debugger for VBScript. I am working with an HTA and repeatedly get errors that cannot be debugged.
 
Have you tried the following to debug?

ON ERROR RESUME NEXT

'Code

IF Err.Number <> 0 THEN
Msgbox Err.Description,,"Err: " & Err.Number
End IF

Everybody body is somebodys Nutter.
 
Yeah, it turned out it was a syntax error, so the code never compiled and I never actually hit any of my debug statements.
 
Or...

Use either the debugger in Visual Studio or the free one you should already have installed (see Microsoft Windows Script Downloads).

Be sure to turn on script debugging via the appropriate registry key setting, default is "no debugging." VBScript 'Stop' Statement Does Not Start Script Debugger

To debug an HTA or an HTML page, be sure to turn on script debugging via IE's Internet Options' "Advanced" tab (Control Panel or IE's Tools menu).

To debug a WSH script, be sure to start cscript or wscript with the /d switch.

Also, see HOWTO: Switch Between the Visual InterDev Debugger and the Microsoft Script Debugger as Default JIT Debugger if this is a relevant issue for you.

There are also techniques to use either of the two script debuggers with server-side ASP pages. Debugging ASP Scripts, Server Script Debugging, etc.


This is the "real" way Windows script is debugged, even though we all resort to a bunch of MsgBox calls at times.

Set breakpoints, examine or change data, resume execution, see source code and have the point of failure highlighted... just like a real debugger should.

See the Help in Script Debugger for more information, or read Introducing Microsoft Script Debugger
 
dilettante,

THANK YOU. I for one had no idea these tools were available.
 
Thanks for the good words.

Be sure and put in a little time to learn your way around one or both of the debuggers. Like any tool, even NotePad, it takes some time to get to the point where you can do things without always looking up details.

Script Debugger can seem a little frustrating at first. It's well worth spending a few hours on it when you get the chance though. Even though it can be used to edit HTML, ASP, and even VBS or JS scripts, they stopped short of making it the nice little IDE it could have been. Maybe that's why it is free.

If you use it to write a script, save the script file out. You can't just "run" a script file loaded or created in Script Debugger directly. [sad]

Then just be sure to flip all of those switches on that I mentioned. Then start the script via cscript/wscript with /d or load your HTM/HTA as usual with debugging ON in IE.

From Script Debugger you can browse running scripts and connect to the one you want to debug. Or, if your script hits an error or a VBScript STOP statement, you'll get a dialog asking whether or not to debug. Just say "yes.
 
I do have debugging turned on in IE. The problem is that IE does not recognize MS Script Debugger as a valid JIT debugger for the error I was getting. It works fine usually.
 
Sorry Tom,

I was just adding general info for anybody else reading the thread.

Some syntax problems do come up in the Debuggers, but others probably don't.

If you have script with [tt]On Error Resume Next[/tt] active there won't an exception to trigger debugging anyway either. You make an excellent point.
 
It turns out it was a stupid syntax error. Very annoying. :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top