How to debug Windows Script Host, VBScript, and JScript files

Tuyên bố miễn trừ trách nhiệm đối với nội dung KB đã hủy

Bài viết này cung cấp thông tin về sản phẩm mà Microsoft không hỗ trợ nữa. Do đó, bài viết này được cung cấp "nguyên trạng" và sẽ không được cập nhật nữa.

Summary

The purpose of this article is to explain how to debug Windows Script Host (WSH) scripts, which can be written in any ActiveX script language (as long as the proper language engine is installed), but which, by default, are written in VBScript and JScript. There are certain flags in the registry and, depending on the debugger used, certain required procedures to enable debugging.

More Information

To debug WSH scripts in Microsoft Visual InterDev, the Microsoft Script Debugger, or any other debugger, use the following command-line syntax to start the script:


wscript.exe //d <path to WSH file>
This code informs the user when a runtime error has occurred and gives the user a choice to debug the application. Also, the //x flag can be used, as follows, to throw an immediate exception, which starts the debugger immediately after the script starts running:


wscript.exe //d //x <path to WSH file>
After a debug condition exists, the following registry key determines which debugger will be used:

HKEY_CLASSES_ROOT\CLSID\{834128A2-51F4-11D0-8F20-00805F2CD064}\LocalServer32
The script debugger should be Msscrdbg.exe, and the Visual InterDev debugger should be Mdm.exe.



If Visual InterDev is the default debugger, make sure that just-in-time (JIT) functionality is enabled. To do this, follow these steps:

  1. Start Visual InterDev.
  2. On the Tools menu, click Options.
  3. Click Debugger, and then ensure that the Just-In-Time options are selected for both the General and Script categories.
Additionally, if you are trying to debug a .wsf file, make sure that the following registry key is set to 1:

HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings\JITDebug
Thuộc tính

ID Bài viết: 308364 - Xem lại Lần cuối: 19-06-2014 - Bản sửa đổi: 1

Phản hồi