Can you debug VBScript in Visual Studio 2013?

2020-02-02 04:25发布

I was wondering if Visual Studio 2013 can run and debug VBScript files?

Thank you for your time.

4条回答
女痞
2楼-- · 2020-02-02 04:56

First of all VBScript is an interpreted language and does not need to be compiled.

But yes, you can debug your VBScript file inside VS2013. Just open the file you want to debug with VS2013. Under "Tools / External Tools" you have to register the Windows Script Host (CScript.exe or WScript.exe) with some startup parameters:

Title:             CScript Debug
Command:           C:\Windows\System32\cscript.exe
Arguments:         //nologo //X $(ItemPath)
Initial directory: $(ItemDir)
Check "Use Output window"
Hit the OK button

In order to start the debugger, just click "Tools / CScript Debug". The VS JIT debugger asks you, wich debugger you want to use. Just select your *.vbs file and click Yes.

Sometimes it is a bit buggy but it works. ;-)

查看更多
小情绪 Triste *
3楼-- · 2020-02-02 05:01

For future readers.

This will work in a pinch.

"C:\Windows\System32\cscript.exe" /x MyFile.vbs

You will be prompted....and you can start a new instance of VS 2xxx (<< Whatever version is installed on your computer).

Not how to do it if you do it all the time..but good for every once in a while.

查看更多
我只想做你的唯一
4楼-- · 2020-02-02 05:02

This worked for me when I wanted to debug slmgr.vbs script:

1) To enable the just in time debugger you have to enable it in the registry:

HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings

set JITDebug=1

2) run command like this:

wscript.exe /x /d slmgr.vbs -xpr

3) The Visual Studio Just-In-Time debugger prompts for a possible debugger. You can just choose New instance of Microsoft Visual Studio 2012, click Yes button.

查看更多
虎瘦雄心在
5楼-- · 2020-02-02 05:10

A debugger that i use is VBsEdit, (click here). It is free to use, and is helpful in getting to the route of a problem quickly, it also comes with a range of scripts that you can use. The one downside with the free version is that every program load will take one second longer than the last, unless you restart VBsEdit or buy the full version. Hope this helps

查看更多
登录 后发表回答