The Windows XP Command Line


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.

Table 25.4. Categories of Command-Line Programs

Types of Commands

Description

Built-in

These commands are built into the command interpreter; for example, dir, copy, and rename.

Native

These commands call .EXE files; for example, sort.EXE, net.EXE, and more.EXE.

Subsystem

These commands are .EXE files from older operating systems that were designed to adjust the environment or interface. They run inside the virtual DOS machine. Examples are DOSKEY, SETVER, himem.sys, and dosx.EXE.

Batch file

These commands direct the flow of Execution in batch files; for example, for, goto, if, and else.

Configuration

These commands go in AUTOEXEC.NT, CONFIG.NT, and CONFIG.SYS in the root drive. They tune the subsystem during startup.


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.

TIP

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.


What's New or Different from MS-DOS

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.

TIP

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.

Also, try typing help xxxx, where xxxx is the name of the program you're interested in. Some commands are documented this way.


Windows XP Commands

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 |


Changes to MS-DOS Commands

Table 25.6 lists some changes and improvements to command line programs that date back to MS-DOS.

Table 25.6. Changes to MS-DOS Commands in Windows XP

Command

Changed Features

chcp

This command changes code pages for full-screen mode only.

cmd

CMD.EXE replaces COMMAND.COM.

del

New switches provide many more functions.

dir

New switches provide many more functions.

diskcomp

Switches /1 and /8 are not supported.

diskcopy

Switch /1 is not supported.

doskey

DOSKEY has several enhancements. However, it functions with 32-bit Windows command line (console) applications only, and is not active in the 16-bit MS DOS environment.

format

Switches /b, /s, and /u are not supported. Adds new filesystem and cluster-size switches.

label

The symbols ^ and & can be used in a volume label.

mode

This command has had extensive changes.

more

New switches provide many more functions.

print

Switches /b, /c, /m, /p, /q, /s, /t, and /u are not supported.

prompt

New character combinations allow you to add ampersands ($a), parentheses ($c and $f), and spaces ($s) to your prompt.

recover

This command recovers files only.

rmdir

The new /s switch deletes directories containing files and subdirectories.

sort

This command does not require the TEMP environment variable. File size is unlimited.

xcopy

New switches provide many more functions.


I'll talk a bit more about some enhanced commands at the end of this chapter, under "Tips from the Windows Pros."

Unavailable MS-DOS Commands

The MS-DOS commands in Table 25.7 are not available at the Windows XP command prompt.

Table 25.7. MS-DOS Commands Not Available in Windows XP

Command

New Procedure or Reason for Obsolescence

assign

Not supported in Windows XP.

backup

Not currently supported.

choice

Not currently supported.

ctty

Not currently supported.

dblspace

Not supported.

deltree

The rmdir /s command deletes directories containing files and subdirectories.

dosshell

Unnecessary with Windows XP.

drvspace

Not currently supported.

emm386

Extended memory support is provided for MS-DOS applications through EMM.SYS, which should appear in CONFIG.NT.

fasthelp

This MS-DOS 6.0 command is the same as the Windows XP command help. Windows XP also provides an online command reference.

fdisk

Disk Management prepares hard disks for use with Windows XP.

include

Multiple configurations of the MS-DOS subsystem are not supported.

interlnk

Not supported. Use the Network Connections Wizard to configure a direct connection via parallel, serial, or infrared (IR) ports.

intersrv

Not supported. Use the Network Connections wizard to configure a direct connection via parallel, serial, or infrared (IR) ports.

join

Filesystems can be joined from the Disk Management console.

memmaker

Windows XP automatically optimizes the MS-DOS subsystem's memory use.

menucolor

Multiple configurations of the MS-DOS subsystem are not supported.

menudefault

Multiple configurations of the MS-DOS subsystem are not supported.

menuitem

Multiple configurations of the MS-DOS subsystem are not supported.

mirror

Not supported in Windows XP.

msav

Not supported.

msbackup

Windows XP provides the optional NTBackup utility (under the Administrative Tools in the Control Panel) for computers with tape drives or the xcopy command for computers without tape drives. Install NTBackup from the \3RDPARTY\MSFT\NTBACKUP folder of the Windows XP CD-ROM.

mscdex

CD-ROM support for MS-DOS applications is provided by mscdexnt, run within AUTOEXEC.NT.

msd

You can use the System Information snap-in instead. To start System Information, choose Start, Run, and then type msinfo32. System Information is much more accurate and much more complete than msd.

numlock

Not currently supported.

power

Not supported.

restore

Not currently supported.

scandisk

Not supported.

smartdrv

Windows XP automatically provides disk caching for the MS-DOS subsystem.

submenu

Multiple configurations of the MS-DOS subsystem are not supported.

sys

Windows XP does not fit on a standard 1.2MB or 1.44MB floppy disk.

undelete

Not supported in Windows XP.

unformat

Not supported in Windows XP.

vsafe

Not supported.


Speeding Up Legacy Programs

Read on if you want to learn how to monitor a 16-bit Windows-based program or an MS-DOSbased program. In Windows XP Professional, 16-bit Windows-based programs run as separate threads in a multithreaded process called Windows Virtual DOS Machine (NTVDM). The NTVDM process simulates a 16-bit Windows environment.

An MS-DOSbased program runs in its own NTVDM process. You can monitor a 16-bit program or an MS-DOSbased program running on your computer with System Monitor by monitoring the NTVDM instance of the Process performance object. Note that 16-bit programs running in an NTVDM appear only if they are started in a separate memory space. If you find that your 16-bit programs are not performing well under Windows XP Professional, you can access some of the program's properties by right-clicking the name of the program in Windows Explorer and configuring the properties as follows:

  • If the program is in a window, and the display performance is slow, on the Screen tab, click Full-Screen.

  • If the program is in a window and seems to pause periodically, click the Misc tab, and set the Idle Sensitivity slider to Low.

You can turn off Compatible Timer Hardware Emulation for the program if performance does not improve by changing the previously described settings. To do so, right-click _DEFAULT.PIF or the program name, select Properties, point to Program, and click Advanced. In the dialog box that appears, clear the Compatible Timer Hardware Emulation check box. This change typically causes a decrease in performance and should be made only if other efforts fail.




Special Edition Using Microsoft Windows XP Professional
Special Edition Using Microsoft Windows XP Professional (3rd Edition)
ISBN: 0789732807
EAN: 2147483647
Year: 2003
Pages: 450

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net