Debug the Javascript/VB script program (wscript)

Source: Internet
Author: User

PreviousArticle"DebuggingJavascript/VB ScriptScriptProgram(IEArticle)"This section describes howIEDebug the script program. During routine maintenance of the operating system, we sometimes write some small script programs to simplify system management, such as calling someWMIFunction to automatically install and uninstall programs.

In actual work, I found that the most complained about the script by programmers is that it is difficult to debug the script program, especially debugging.. VbsAnd so onWshAlways:

1.Double-click. VbsFile.

2.An error occurs in the program, such as an exception or a programming logic error.

3.Read the source file in one row, and add a lotMsgbox. Show, Print the values of some variables.

4.Re-Execute. VbsFile

5."Dangdang", a series After I click "OK", the user will also be dizzy and go back to Step 3 to continue ......

In fact, we can also useVisual StudioDebuggingWshProgram, the key lies in. VbsAnd so onWshInterpreter of the script programWscript.exeAndCscript.exeDebugging support:

1.When we double-click. VbsThe resource manager is actually runningWscript.exeTo explain and execute this. VbsFile.

2.Wscript.exeAndCscript.exeBoth options are supported./D-Enable debugging,/X-Execute the script program in the debugger.

In this way, we can use the following two methods:Visual StudioDebug the script program. Here I will only introduce the second method.--The first method does not know why myWin 7 + Visual Studio 2008Cannot work, .

For example. VbsCode, Save itC: "test. vbsTo debug this program, the source file is as follows:

SetOBJ = Createobject ("System. Collections. arraylist")

OBJ. Add ("This is a test")

OBJ. Add (1)

OBJ. Add (OBJ)

 

Msgbox OBJ (0)

Msgbox OBJ (1)

Msgbox OBJ (2). tostring ()

 

1.Open the command line and change the directoryC:Disk, run the following command:

Wscript.exe/X test. vbs

2.At this time,Visual StudioDialog box, prompting you to select the appropriate debugger, just click the OK button above.

3.Finally, you can start debugging.C #OrC ++Similar to programsVisual StudioSet a breakpoint to view the value of the variable, as shown in:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.