Running VBScript and JScript files from the Command Shell
Using the Windows script host to run scripts from the command line is discussed. Some specific examples are given.


Windows XP comes with two interfaces for running VBScript and JScript (Microsoft's version of JavaScript) files. The default is a graphical user interface using Wscript.exe . However, there is also a command-line interface, Cscript.exe . It is often more convenient to use the command line for scripts and Windows XP actually comes with a number of useful scripts for system administration that need to be run from the command prompt.

Configuring the command shell to run scripts

Many scripts for computer management are more conveniently run from the command shell so that the user does not have to deal with the complications of windows and dialog boxes from the graphical user interface. It can be easier to handle output in a command window. One way to run a script in the command line is to preface the script with the executable Cscript.exe . For example, a statement of the form cscript.exe somescript.vbs can be entered into the command line and somescript.vbs will then run in the command window. Note, however, that the fully qualified path must generally be used and pathnames with spaces must be enclosed in quotation marks. To make the script processor Cscript the default host for scripts, enter into the command line wscript //H:cscript Scripts can be then be run by simply entering into the command line somescript.vbs The default can be returned to the graphical interface with the command wscript //H:wscript

Some scripts that come with Windows XP

Tucked away in the folder \Windows\System32\ are some files in VBScript format that most PC users have never heard of. Also included with the two system tool packages discussed on other pages are some tools that are in the form of scripts. Some of these are really just for administrators but there are several that might be of use to the average PC owner. They are listed below. More detail about these scripts is in the Windows XP Help and Support Center. Running these scripts is easier if Cscript is made the default interface.

Eventquery.vbs
Lists the events and event properties from one or more event logs.Can be used with a filter to specify the types of events to include in or exclude from the query.
Pagefileconfig.vbs
Enables an administrator to display and configure a system's paging file Virtual Memory settings
Prncnfg.vbs
Configures or displays configuration information about a printer. Used without parameters, prncnfg.vbs displays command-line help.
Prndrvr.vbs
Adds, deletes, and lists printer drivers. Used without parameters, prndrvr.vbs displays command-line help.
Prnjobs.vbs
Pauses, resumes, cancels, and lists print jobs. Used without parameters, prnjobs.vbs displays command-line help.
Prnmngr.vbs
Adds, deletes, and lists printers or printer connections, in addition to setting and displaying the default printer. Used without parameters, prnmngr.vbs displays command-line help.
Prnport.vbs
Creates, deletes, and lists standard TCP/IP printer ports, in addition to displaying and changing port configuration. Used without parameters, prnport.vbs displays command-line help.
Prnqctl.vbs
Prints a test page, pauses or resumes a printer, and clears a printer queue. Used without parameters, prnqctl.vbs displays command-line help.

Windows Management Instrumentation Command-line (WMIC) tool

WMIC is a command-line and scripting interface that simplifies the use of Windows Management Instrumentation (WMI). WMIC is based on aliases. Aliases make the primary data provided by WMI available without having to understand WMI-specific concepts.More details are at this Microsoft reference . Information is also available on a local computer by entering into a command prompt WMIC /? One use of WMIC is to write simple scripts to automate the management of a computer.

Back to top

Popular Pages