Executing Scripts

Windows XP supplies two programs used to run WSH scripts (whatever language they are written in). wscript.exe is used to run WSH scripts from the Windows graphical environment, and cscript.exe is used to run them from the command line or from within batch files. Both programs are fully documented in Chapter 4.

Using wscript.exe

Using wscript.exe , you can run scripts under Windows in the following ways:

  • Double-click on script files or icons listed in My Computer, Windows Explorer, the Find window, the Start menu, or on the Desktop.

  • If you double-click a script file whose extension has not yet been associated with wscript.exe, an Open With dialog box appears asking which program you would like to use to open the file. After choosing WScript, check the “Always use this program to open this file” checkbox, and WScript is registered as the default application for all files with the same extension as the one you double-clicked.

  • Enter wscript, followed by a script name at the Run command on the Start menu or at any command prompt. You must enter the full name of the script, including the file extension and any necessary path information.

Although the wscript.exe application has several command-line parameters (see “Windows Script Host” in Chapter 4), it’s more convenient to use the Properties window of a script file (right-click the file and select Properties). Options are set in the usual way, but the properties are not saved in the script file or in the Registry as you ...

Get Windows XP in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.