Despite the ease of use of the Windows graphical user interface, the command-line interface provides a useful way to perform many maintenance, configuration, and diagnostic tasks. Many of the most important diagnostic tools such as ping, tracert, and nslookup are only available from the command line, unless you purchase third-party graphical add-ons to perform these functions. Using batch files remains a useful way to encapsulate common management functions; batch files (or shortcuts to batch files) can be placed in shared folders as a way of distributing management functions on a network. Together, command-line utilities and scripts run with either Windows Scripting Host (wscript) or the command-line-based scripting host (cscript.EXE) provide a complete set of building blocks from which you can build very high-level utilities if normal Windows commands aren't sufficient for your needs.
The Windows XP Professional command-line utilities include many of the same programs found in DOS and earlier versions of Windows. In many cases, the programs have been enhanced considerably. Utilities not found in DOS or Windows 9x are also available.
Command-line programs fall into five categories, as shown in Table 25.4.
The command interpreter (the shell) in Windows XP is, by default, CMD.EXE. The CMD.EXE command interpreter is similar to DOS's old COMMAND.COM shell but has enhanced batch file functions and also has built-in command-line editing and a command history function similar to that provided by DOSKEY in DOS and Windows 9x. You don't need DOSKEY in Windows XP, unless you want to use its command aliasing feature.
Many of the built-in commands are significantly enhanced since Windows 9x and NT 4. To see a complete list of command-line utilities along with syntax and usage examples, open the Help and Support Center and search for Command-line reference A-Z. Click each command for use, syntax, and examples.
To learn how to get the most from the scripting and the Command Line environment, get Brian's book Windows XP Under the Hood: Hardcore Windows Scripting and Command Line Power, published by Que.
Windows XP retains and enhances almost all the functionality of MS-DOS. The following sections explain new Windows XP commands not found in MS-DOS, changes to MS-DOS commands, and unavailable MS-DOS commands.
You can see the command line syntax and options for most commands by typing the command name followed by /? in a command prompt window. For example, rasdial /? lists the options for the rasdial command.
The online command line reference provides more detail. See the previous tip to find out how to view the command line reference.
Table 25.5 lists most of Windows XP's command-line commands. Some may be used only by a Computer Administrator.
Table 25.5. Windows XP Command-Line Commands
Command | Function | Command | Function |
---|
arp | Displays and edits the ARP cache | cipher | Encrypts and decrypts files and folders |
asr_fmt | Automated System Recovery backup and restore | clspack | Lists Java system packages |
asr_ldm | Automated System Recovery Logical Disk manager | cmd | Command shell |
assoc | Associates filename extensions with file types | compact | Enables and disables file and folder compression |
atmadm | Manages ATM network connections | convert | Schedules the conversion of a volume from FAT to NTFS |
attrib | Displays and sets file/folder attributes | cscript | Windows Script Host (command command-line version) |
bootcfg | Modifies the BOOT.INI configuration file | defrag | Defragments a disk volume |
cacls | Clears the Command Prompt window | diantz | Compress files into a .CAB file (same as makecab) |
chkntfs | Schedules automatic chkdsk at boot time | diskpart | Manages disk partitions |
diskperf | Starts the physical disk performance counters | getmac | Displays network adapter MAC addresses |
driverquery | Lists the installed device drivers | goto | Goes to the label in a batch file |
endlocal | Restores environment variables | gpresult | Computes and displays Group Policy Resultant Set of Policy |
esentutl | MS database utility | gpupdate | Forces the update of Local and Group Policy settings |
eventcreate | Adds an event to the event log | graftabl | Enables the display of graphics characters in the MS-DOS environment |
eventquery | Lists events from the event log | graphics | Loads the graphics printer driver (obsolete) |
eventtriggers | Displays and configures event triggers | grpconv | Program Manager Group converter |
expand | Expands a file from a .CAB file | help | Displays command command-line program usage information |
find | Finds text in files | hostname | Displays the local computer's TCP/IP hostname |
findstr | Finds text in files using regular expressions | iexpress | Creates simple Installer applications |
finger | Displays information about a user (UNIX) | if | Executes a command conditionally |
for | Repeat command (many options) | ipconfig | Displays the TCP/IP configuration and manages DHCP leases |
forcedos | Runs a program in the MS-DOS environment | ipsec6 | Configures IPSec over IPv6 security |
format | Formats a fixed or removable disk | ipvg | Installs and configures IPv6 |
fsutil | Manages the Windows file system | ipxroute | Displays and edits the IPX/SPX protocol's routing table |
ftp | File Transfer Protocol | jdbgmgr | Microsoft debugger for Java |
ftype | Associates file types to "open" commands | jview | Command-line loader for Java |
label | Sets the volume label on a disk or mount point | mqbkup | MS Message Queue backup and restore utility |
loadfix | Runs an program above the first 64KB of memory | mrinfo | Multicasts routing using SNMP |
loadhigh | Loads an MS-DOS TSR program into high memory | mscdexnt | MS CD Extensions, loaded in AUTOEXEC.NT |
lodctr | Installs, backs up, or restores performance performance-counter definitions | msg | Sends a message to anotheruser |
logman | Schedules the automatic collection of performance information | nbtstat | Displays NetBIOS-over-TCP/IP statistics and name tables |
logoff | Logs off from Windows | net | Networking management utility |
lpq | Displays the printer queue (UNIX) | netsh | Network-configuration utility |
lpr | Prints a file (UNIX) | netstat | Displays the current TCP/IP connections and open sockets |
makecab | Compresses files into a .CAB file | nlsfunc | Loads country/region information |
md | Creates a directory (same as mkdir) | nslookup | Query Queries DNS servers |
mem | Displays free memory in the MS-DOS subsystem | ntsd | System-level debugger |
mkdir | Creates a directory (same as md) | ntvdm | MS-DOS virtual machine environment |
mode | Configures port, display, and keyboard settings | nw16 | Netware NetWare 16-bit redirector, loaded in AUTOEXEC.NT |
more | Displays text a page at a time | odbcconf | Configures ODBC drivers and data sources |
mountvol | Creates, deletes, and lists volume mount points | openfiles | Displays files in use by local processes or network users |
move | Moves files or folders | pagefileconfig | Manages the virtual memory pagefile |
path | Sets the command search path | qprocess | Displays information about processes (local or remote) |
pathping | Tests TCP/IP connectivity | qwinsta | Displays information about Terminal Services sessions |
pause | Stops a batch file until the user presses Enter | rasautou | Creates a RAS connection |
ping | Tests TCP/IP connectivity | rasdial | Starts and ends Dial-up Networking connections |
ping6 | IPv6 Ping | rasphone | Pop-up Dial-up Networking manager |
popd | Restores the current directory | rcp | Copies files to another computer (UNIX) |
print | Copies a file to a local LPT-port printer | rd | Removes a directory (same as rmdir) |
prncnfg | Configures printers | recover | Extracts data from a damaged disk |
prndrvr | Installs and lists print drivers | redir | Networking redirector, loaded in AUTOEXEC.NT |
prnjobs | Manages print jobs | reg | Edits or displays Registry data |
prnmngr | Manages local and network printer connections | regini | Creates Registry entries and sets permissions |
prnport | Manages TCP/IP printers | regsvr32 | Registers a .DLL file as a COM computer |
prnqctl | Prints test pages, as well as starts and stops the printer queue | relog | Changes the format or rate for performance log files |
prompt | Sets the command command-line prompt | rem | Remarks or comments text |
proxycfg | Sets the HTTP Proxy server | ren | Renames files or folders (same as rename) |
pubprn | Publishes printers to Active Directory | rename | Renames files or folders (same as ren) |
pushd | Saves the current directory | replace | Replaces files |
qappsrv | Displays the available application terminal servers on the network | reset | Deletes a Terminal Services session |
rEXEc | UNIX remote execute | share | (Does nothing on Windows XP) |
rmdir | Removes a directory (same as rd) | shift | Deletes and moves command command-line arguments |
route | Displays or edits the current routing tables | shutdown | Shuts down, logs off, or restarts a computer |
rsh | Remote shell (UNIX) | sort | Sorts text files alphabetically (filter) |
rsm | Manages removable storage media pools | start | Runs a command or opens a document in a new window |
runas | Runs a program with another user's credentials | subst | Maps a drive letter to a local folder |
rundll32 | Launches a 32-bit DLL program | syskey | Encrypts and secures the system database |
rwinsta | Resets the session subsystem hardware and software to their known initial values | systeminfo | Displays a system hardware and software summary |
sc | Displays and manages installed services | taskkill | Terminates a process |
schtasks | Displays and manages scheduled tasks | tasklist | Lists active processes |
sdbinst | Application compatibility database installer | telnet | Establishes a command-line session on another computer |
set | Sets environment variables | tftp | Trivial File Transfer Protocol |
setdebug | Enables and disables ActiveX debugging for Java | time | Displays and sets the time of day |
setlocal | Saves the current environment | title | Sets the window title |
setver | Lies about the MS-DOS version to old applications | tlntadmn | Telnet Server Administrator |
sfc | Verifies system file integrity | tlntsess | Displays the current Telnet sessions |
shadow | Monitors or controls a Terminal Services session | tracerpt | Gathers or summarizes event trace information |
tracert | Checks TCP/IP connectivity | vssadmin | Displays shadow copy backups and providers |
TRacert6 | IPv6 trace route | vwipxspx | NetWare protocol stack, loaded in AUTOEXEC.NT |
tree | Displays the directory structure | wmic | Queries and manages Windows XP via Windows Management Instrumentation |
tsdiscon | Disconnects a Windows/Terminal Services session | wscript | Windows Script Host (windowed version) |
tskill | Terminates a process in a Terminal Services session | xcopy | Copies multiple files |
tsprof | Copies and manages Terminal Services user profiles | & | Separates multiple commands on the command line. |
tsshutdn | Shuts down or restarts a Terminal Services server profiles | && | Separates multiple commands. Command following && runs only if the command preceding && succeeds |
type | Copies a text file to the console window | | | Seperate commands. Output of the command preceding | is sent as input to command after | |
typeperf | Displays performance data | || | Seperates commands. Command following || runs only if the command preceding || symbol fails |
unlodctr | Removes performance performance-counter definitions | ( ) | Groups commands |
verify | Controls automatic verify-after-write | ; or, | Separates parameters |
| | ^ | Escape character, removes special meaning from characters like & and |. For example, ^| is treated as ordinary text | |
Table 25.6 lists some changes and improvements to command line programs that date back to MS-DOS.
I'll talk a bit more about some enhanced commands at the end of this chapter, under "Tips from the Windows Pros."
The MS-DOS commands in Table 25.7 are not available at the Windows XP command prompt.