[英]How do I debug a stand-alone VBScript script?
I have a VBScript script that takes 2 command-line arguments and does some validation. 我有一个VBScript脚本,需要2个命令行参数并进行一些验证。 I need to debug this to see how the program is getting executed.
我需要调试它以查看程序是如何执行的。 I was trying to paste this into Excel (using VBA ).
我试图将其粘贴到Excel中(使用VBA )。 However there are some constructs like
Const
, etc. that are not being supported, plus certain validations like taking the command-line arguments are failing. 但是,有些构造类似
Const
等不受支持,加上某些验证(如获取命令行参数)失败。
Hence I would like to know if there is any way to debug this script. 因此,我想知道是否有任何方法来调试此脚本。 I have Windows XP and Office 2003 installed.
我安装了Windows XP和Office 2003。 I cannot install any other applications on the office computer.
我无法在办公室计算机上安装任何其他应用程序。
Run cscript.exe for full command args, I think 我认为运行cscript.exe以获取完整的命令args
cscript //X scriptfile.vbs MyArg1 MyArg2
will run the script in a debugger. 将在调试器中运行该脚本。
Click the mse7.exe
installed along with Office typically at \\Program Files\\Microsoft Office\\OFFICE11
. 单击与Office
mse7.exe
安装的mse7.exe
通常位于\\Program Files\\Microsoft Office\\OFFICE11
。
This will open up the debugger, open the file and then run the debugger in the GUI mode. 这将打开调试器,打开文件,然后在GUI模式下运行调试器。
For posterity, here's Microsoft's article KB308364 on the subject. 对于后人,这里是微软关于这个主题的文章KB308364 。 This no longer exists on their website, it is from an archive .
它不再存在于他们的网站上, 而是来自存档 。
How to debug Windows Script Host, VBScript, and JScript files
如何调试Windows脚本宿主,VBScript和JScript文件
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.
本文的目的是解释如何调试Windows脚本宿主(WSH)脚本,它可以用任何ActiveX脚本语言编写(只要安装了正确的语言引擎),但默认情况下是用VBScript编写的和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:
要在Microsoft Visual InterDev,Microsoft脚本调试程序或任何其他调试程序中调试WSH脚本,请使用以下命令行语法来启动脚本:
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
.脚本调试器应该是Msscrdbg.exe,Visual InterDev调试器应该是
Mdm.exe
。If Visual InterDev is the default debugger, make sure that just-in-time (JIT) functionality is enabled.
如果Visual InterDev是默认调试器,请确保启用实时(JIT)功能。 To do this, follow these steps:
为此,请按照下列步骤操作:
Start Visual InterDev.
启动Visual InterDev。
On the Tools menu, click Options.
在“工具”菜单上,单击“选项”。
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:
此外,如果您尝试调试.wsf文件,请确保将以下注册表项设置为1:
HKEY_CURRENT_USER\\Software\\Microsoft\\Windows Script\\Settings\\JITDebug
PROPERTIES
性能
Article ID:
308364
- Last Review: June 19, 2014 - Revision: 3.0文章编号:
308364
- 最后修改:2014年6月19日 - 修订:3.0Keywords:
kbdswmanage2003swept kbinfo KB308364
关键词:
kbdswmanage2003swept kbinfo KB308364
将此文件夹导出到备份文件,然后尝试删除此文件夹和所有内容。
HKEY_CURRENT_USER\Software\Microsoft\Script Debugger
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.