O'Reilly logo

Windows XP Annoyances for Geeks, 2nd Edition by David A. Karp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a Script with VBScript

A script is simply a list of commands that are placed one after another and stored in a text file. Script commands are like building blocks: the more commands and programming techniques you learn, the broader your palette will be for making useful scripts. Some of the simpler building blocks will be used in this section of the chapter to illustrate the way scripts are built. Advanced users may prefer to skip to subsequent sections, which cover more advanced topics.

To run a script, just double-click on the script file icon; you'll probably never need to run the Scripting Host program (wscript.exe) directly.

Tip

There are actually two script interpreters (engines) included with Windows XP. WScript.exe is a native Windows interpreter and is used in most cases. CScript.exe is a console interpreter, which is used when you want the script output to be sent to the console (Command Prompt). You can use CScript.exe at any time by right-clicking a script file and selecting Open with Command Prompt.

When the Scripting Host runs the script, the commands are executed in order, one by one. You can leave Notepad open to make changes and additions while you test the script (big screens are especially handy for this sort of thing).

You can quickly open an existing script file for editing by right-clicking on it and selecting Edit. This will, by default, open Notepad, although you might want to associate the Edit action for .vbs files with a more powerful text editor (see ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required