Windows Commands

Windows Commands

Entering Commands

Command options are generally preceded by a forward slash

Multiple commands may be concatenated by an ampersand: command1 &

command2. The commands are executed in sequence.

Commands may be executed conditionally, based on the success or failure of a

preceding command, by joining them with && or || (respectively).

I/O Redirection

< file, > file, 1> file, >> file, 1>> file, 2 > file, 2 >> file, > file 2 >&1

command1 | command2, command1 0 > command2

Form a pipe, linking the standard output of command1 to the standard input of


Environment Variables

Environment variables are dereferenced by enclosing the name between percent signs.


Help Commands

help command, command /?

net help command

Obtain help for one of the net commands.

net helpmsg nnnn

Explain Windows 2000 message number nnnn.

cmd [options] [ /C | /K [ /S ] command]

Start a new Windows 2000 command interpreter. If command is specified, that command is


date [mm-dd-[yy]yy] [/T] The /T option displays the date without modifying it.

doskey [options]

Recall previous commands or create macros (aliases).

/HISTORY Display the entire command history list.

/LISTSIZE=n Set the size of the history list to n.

find [options] string [files]

/V Display only nonmatching lines.

/I Perform a case-insensitive search

/C Display a count of matching lines only.

/N Display the line number preceding each line.

findstr [options] /C:string | /G:file | strings [files]

/R Interpret search strings as regular expressions.

/L Interpret search strings as literal text.

logoff /F /N End the current logon session, suppressing all confirmation prompts.

more [options] [files]

/C Clear the screen before displaying the first page.

/S Combine (squeeze) multiple blank lines into one.

+n Begin the display at line n of the input or first file.

now string Precede the specified string with the current date and time

path [path] Display or set the search path

sort [options] [< file]

/R Reverse usual sort order.

/+n Start sorting in column n.

time [hr[:min[:sec[.hd]]]] [A | P] [/T]

title string Set the title of the current command (cmd.exe) window.

Whoami Display the username of the currently logged-in user.

assoc [.ext=filestypename] Associate a file extension with a named file type.

ftype [filetypename=command-string]

Display (no parameters) or define file type-specific command invocations.

net computer \\host /ADD | /DELETE

Add or remove the specified computer from the domain database.

net name [name] [/DELETE]

net send who message

shutdown \\remote-host | /L [options] [message]

/R Reboot after shutting down.

/T:n Wait n seconds before shutting down (the default is 20).

/Y Answer yes to all subsequent prompts.

/A Abort a pending shutdown.

attrib [options] [files]

Set DOS file attributes (or display the current attributes if no options are specified). The file

list defaults to all files in the current directory.

comp [options] fileset1 fileset2 Compare two sets of files

compact [options] [files] Compress or uncompress the specified files

copy [options] source destination

If destination is a single file, all source files are concatenated.

del [options] files Delete files. erase is a synonym for del.

dir [options] [path]

/S Recurse subdirectories.

fc [options] fileset1 fileset2

Compare files or sets of files, displaying the differences between them. If multiple source

files are specified, files of the same name in the second file set are compared.

move [/Y] files destination

Move files to new directory location. Use /Y to suppress overwrite confirmation prompts.

net file [id [/CLOSE]]

Without arguments, list all open shared files and their ID numbers. When an id is specified,

information about that item is displayed and the /CLOSE option closes the file.

ren path new-name Rename the specified file. rename is a synonym for ren.

replace source-files destination [options]

Replace/update files in a destination directory.

/A Add new files to the destination directory

type file Display file contents.

xcopy files destination [options] Copy directory trees.

/EXCLUDE: file

/S Recurse nonempty subdirectories.

/E Include empty directories

/C Continue copying even if an error occurs.

Working with Directories

cd [/D] [path]

Display or set the current working directory. Use /D to change to the current directory on the specified drive when it is different from the current drive.

diruse [/*] [dirs]

Compute and display disk space usage by directory for the specified directories (or the top-

level folders within the specified directories, if the option is included).

md[mkdir] path

rd[rmdir] [options] path

/S Remove the entire subtree.

tree dir[options]

Display the tree structure for the specified directory.

/F Include filenames in the display.

Working with Disks and Filesystems

chkdsk x:[options] Check the filesystem on Drive x.

/F [/X] Fix any errors encountered. /X forces a volume dismount before the check.

/R Locate and recover bad sectors.

diskuse [path] [options]

Display disk space usage by user account for the current or specified directory tree.

format x: [options]

Format the disk partition designated by drive letter x (or the diskette in Drive x:).

label [x:] [label]

Assign the volume label for Drive x (defaults to the current drive). If no label is specified, you

are prompted for it.

Managing Shares

net share share-name[=path] [options] [/DELETE]

Make a directory available to the network or revoke shared access (the =path form is used

only when defining a new shared resource).

Without arguments, the command lists all currently shared resources.

net use [device:] [\\host\share] [password | *] [options] [/DELETE]

Map a network resource to a local device, which can be a drive letter or a printer of the form


net view [target]

Display the names of the computers in a domain or network, or display the shared resources

on a specified remote system.


con2prt, lpq, lpr,

print /D:\\server\ print_share files Print text files on the specified remote printer.

Networking-Related Commands

finger [user][@host] Display information about the specified local or remote use

ftp host | IP-address, hostname, telnet

arp Display and manipulate physical address-IP address translation.

arp /A [IP-address] [/N interface-address] Display current mapping

arp /S IP-address physical-address [interface-address]

arp /D IP-address [interface-address]

ipconfig [/ALL]

ipconfig /RENEW | /RELEASE [adapter]


Display or flush the contents of the DNS resolver cache.


Reregister all current DHCP names with the DNS.

net session [\\host] [/DELETE]

Without arguments, display session information for all connections to the local system.

The /DELETE option causes the specified session or all sessions to terminate, closing all associated open local files.

net statistics [SERVER | WORKSTATION]

netsh [context subcommand ...]

The network subsystem administration utility. This facility, which can function either in interactive mode or as a standalone command utility, provides support for command-line/script-based management of many network facilities, including DCHP (dhcp context keyword), network interface (interface), routing (routing), Remote Access Services (ras), and WINS (wins).

Specify the primary DNS server for the local system:

netsh interface ip set dns "Local Area Connection" ^ static ip-addr

Add an exclusion range to an existing DHCP scope:

netsh dhcp server scope name add excluderange ^ ip-addr1 ip-addr2

netstat [options] [n] /N, /R, /P protocol

nslookup [host] [DNS server]

Perform DNS name translation, using the designated DNS server, if specified. Without options, this command enters interactive mode.

pathping [options] destination

Trace routes to the destination, showing the degree of packet loss at each router/link.

ping [options] destinations /l length

route [options] [cmd [dest] [MASK netmask] [gateway] ^ [METRIC hops]]

View or modify the routing table. cmd is one of the following: PRINT, ADD, DELETE, CHANGE

/F Clear all gateway entries from the routing table.

/P Use with ADD to define a persistent route, which survives system reboots.

tracert host | IP-address Display the route to the specified destination.

Administering Users and Groups

net accounts /sync

Force an update of the user accounts database.

net accounts options [/DOMAIN]

Modify the system or domain password policy settings.


net localgroup

net user username [passwd |*] ^ [/ADD [options] | /DELETE]


Create or modify user accounts. As indicated, the username can be followed optionally by a

password or by an asterisk to request a password promp

Managing Processes

at List or schedule delayed and periodic tasks on the specified computer system.

at [\\host] job-ID /DELETE

at [\\host] /DELETE [/YES]

at [\\host] time [options] command

kill [/F] item


Write a listing of all current processes and their memory usage statistics to the file memsnap.log.

net print \\host\shared-printer

List the contents of the specified print queue.

net print [\\host] job-number [/HOLD | /RELEASE | /DELETE]


Continuously display a list of currently running processes, as well as the overall system memory and paging statistics.

runas /user:username command Execute a command as the specified user.

start [window-title] [options] command

/Ddir Set the current working directory for the command.

/B Start the command as a background process—don't create a new window.

net config [SERVER | WORKSTATION] [options]

Set configuration information for or display information about the Server and Workstation services.

net continue[pause, start, stop] service,

Accessing the System Registry

reg op args [options] Perform various registry operations.

netdiag [options] [/Q | /V | /DEBUG,/FIX]

Test various aspects of network connectivity for the local server.

netdom action [options] Manage Windows NT/2000 domains and trust relationships.

Script-Related Constructs


%m The argument number m. (Access arguments above the ninth one via the shift command.)

%* Corresponds to all command parameters.

%var % Value of variable var (local or environment).

Commands Useful in Scripts

call file | :label [args]

Run the specified external script file or labeled subroutine within the current script.

cls Clear the screen.

sleep secs

rem anything

echo message

echo ON | OFF

Enable or disable command echoing (it is enabled by default).

Pause Pause execution until the user presses a key.

prompt text Set the command prompt to text,

$D, $T Current date, current time.

$G Greater than sign (>).

$N Current drive letter.

$P Current drive and working directory.

set [var]

Display the value of the specified variable (or of all defined variables).

set var=string

Set the value of a string variable.

set /A var=numeric-expression

Set the variable to the result of the evaluated numeric expression.

shift [/n]

Shift script or command arguments down one place, starting at argument n (if specified).


Windows 2000 Commands Pocket Reference

Post a Comment


Java (159) Lucene-Solr (110) Interview (61) All (58) J2SE (53) Algorithm (45) Soft Skills (36) Eclipse (34) Code Example (31) Linux (24) JavaScript (23) Spring (22) Windows (22) Web Development (20) Nutch2 (18) Tools (18) Bugs (17) Debug (15) Defects (14) Text Mining (14) J2EE (13) Network (13) PowerShell (11) Troubleshooting (11) Chrome (9) Design (9) How to (9) Learning code (9) Performance (9) UIMA (9) html (9) Http Client (8) Maven (8) Problem Solving (8) Security (8) bat (8) blogger (8) Big Data (7) Continuous Integration (7) Google (7) Guava (7) JSON (7) ANT (6) Coding Skills (6) Database (6) Scala (6) Shell (6) css (6) Algorithm Series (5) Cache (5) Dynamic Languages (5) IDE (5) Lesson Learned (5) Programmer Skills (5) Tips (5) adsense (5) xml (5) AIX (4) Code Quality (4) GAE (4) Git (4) Good Programming Practices (4) Jackson (4) Memory Usage (4) Miscs (4) OpenNLP (4) Project Managment (4) Spark (4) System Design (4) Testing (4) ads (4) regular-expression (4) Android (3) Apache Spark (3) Become a Better You (3) Concurrency (3) Eclipse RCP (3) English (3) Happy Hacking (3) IBM (3) J2SE Knowledge Series (3) JAX-RS (3) Jetty (3) Restful Web Service (3) Script (3) regex (3) seo (3) .Net (2) Android Studio (2) Apache (2) Apache Procrun (2) Architecture (2) Batch (2) Bit Operation (2) Build (2) Building Scalable Web Sites (2) C# (2) C/C++ (2) CSV (2) Career (2) Cassandra (2) Distributed (2) Fiddler (2) Firefox (2) Google Drive (2) Gson (2) How to Interview (2) Html Parser (2) Http (2) Image Tools (2) JQuery (2) Jersey (2) LDAP (2) Life (2) Logging (2) Python (2) Software Issues (2) Storage (2) Text Search (2) xml parser (2) AOP (1) Application Design (1) AspectJ (1) Chrome DevTools (1) Cloud (1) Codility (1) Data Mining (1) Data Structure (1) ExceptionUtils (1) Exif (1) Feature Request (1) FindBugs (1) Greasemonkey (1) HTML5 (1) Httpd (1) I18N (1) IBM Java Thread Dump Analyzer (1) JDK Source Code (1) JDK8 (1) JMX (1) Lazy Developer (1) Mac (1) Machine Learning (1) Mobile (1) My Plan for 2010 (1) Netbeans (1) Notes (1) Operating System (1) Perl (1) Problems (1) Product Architecture (1) Programming Life (1) Quality (1) Redhat (1) Redis (1) Review (1) RxJava (1) Solutions logs (1) Team Management (1) Thread Dump Analyzer (1) Visualization (1) boilerpipe (1) htm (1) ongoing (1) procrun (1) rss (1)

Popular Posts