CMD COMMANDS

Here's the ultimate Windows XP/2000 command list that will make any Linux user feel at home at the command prompt. A lot of these commands are intended for administrating a network, but they are great for savvy home users as well.  We even listed which OS you need for these commands.
  • at (windows XP/2000)
    Scheduling utility.
  • bootcfg (XP only)
    This utility allows you to set up your boot options, such as your default OS and other loading options.
  • cacls (XP, 2000, & NT4.0)
    Changes the ACLs (security Settings) of files and folders. Very similar to chmod in Linux. 
  • comp (XP & 2000)
    This utility is very similar to diff in Linux.  Use the /? switch to get examples of command usage.
  • contig (works with NT4.0 and newer)
    A great defrag utility for NTFS partitions.
  • control (XP only) - unpublished!
    Allows you to launch control panel applets from the command line. 
control userpasswords2, for example will launch a helpful local user admin utility.
  • defrag (XP only - NT4.0 and Win2k use contig)
    Yes, XP comes with a command line disk defrag utility. If you are running Win2k or NT4.0 there is still hope. Contig is a free defrag program that I describe on the defrag page.
  • diskpart (XP only)
    Use this command to manage your disk partitions.  This is the text version for the GUI Disk Manager.
  • driverquery (XP only)
    Produces a list of drivers, their properties, and their versions. Great for computer documentation.
  • eudcedit (XP only) -
unpublished!
Private Character editor.  Yes with this program built into Windows XP you can create your own font!
  • findstr
    Find String - similar to Linux's Grep.
  • fsutil (XP only) - unpublished!
    This is a utility with a lot of capability.  Come back soon for great examples.
  • getmac (XP & 2000)
    This command gets the Media Access Control (MAC) address of your network cards.
  • gpresult (XP & 2000)
    This generates a summary of the user settings and computer group policy settings.
  • gpupdate (XP only)
    Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.
  • ipconfig (XP, 2000 & NT4.0)
    This handy tool displays IP settings of the current computer and much more.
  • MMC (XP, 2000 & NT4.0) - Microsoft Management Console
    This is the master tool for Windows, it is the main interface in which all other tools use starting primarily in Windows 2000 and newer systems.
  • more
    Utility used to display text output one screen at a time. Ex. more c:\windows\win.ini
  • msconfig (XP only)
    The ultimate tool to change the services and utilities that start when your Windows machine boots up. You can also copy the executable from XP and use it in Win2k.
  • msinfo32 (XP &smp; 2000)
    An awesome diagnostic tool. With it you can get a list of running processes, including the residing path of the executable (great for manually removing malware) and get detailed information about hardware and system diagnostics.
  • narrator (XP only)
    Turns on the system narrator (can also be found in accessibility options in control panel).  Will will allow your computer to dictate text to you.
  • netsh (XP & 2000)
    A network configuration tool console.  At the 'netsh>' prompt, use the '?' to list the available commands and type "exit" to get back to a command prompt.
  • netstat (XP)
    A local network port tool - try netstat -ano.
  • nslookup (all)
    A DNS name resolution tool.
  • openfiles (XP Only)
    Allows an administrator to display or disconnect open files in XP professional. Type "openfiles /?" for a list of possible parameters.
  • Pathping (XP & 2000)
    A cross between the ping and traceroute utilities. Who needs Neotrace when you can use this? Type "pathping <ip address>" and watch it go.
  • recover (XP & 2000)
    This command can recover readable information from a damaged disk and is very easy to use.
  • reg (XP & 2000)
    A console registry tool, great for scripting Registry edits.
  • sc (XP & 2000)
    A command line utility called the Service Controller.  A power tool to make service changes via a logon/logoff or startup/shutdown script.
  • schtasks (XP only)
    A newer version of the AT command.  This allows an administrator to schedule and manage scheduled tasks on a local and remote machines.
  • secedit (XP & 2000)
    Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.  Example to update the machine policy: secedit /refreshpolicy machine_policy /enforce
    To view help on this, just type secedit.
    NOTE: In Windows XP SP1 and news, this command is superceded by: gpupdate /force
  • sfc (XP & 2000)
    The system file checker scans important system files and replaces the ones you (or your applications) hacked beyond repair with the real, official Microsoft versions.
  • shutdown (XP & 2000)
    With this tool, You can shut down or restart your own computer, or an administrator can shut down or restart a remote computer.
  • sigverif (XP only)
    Microsoft has created driver signatures. A signed driver is Microsoft tested and approved. With the sigverif
  • systeminfo (XP only)
    Basic system configuration information, such as the system type, the processor type, time zone, virtual memory settings, system uptime, and much more.  This program is great for creating an inventory of computers on your network.
  • sysedit (XP/2000)
    System Configuration File Editor.  An old tool that was very handy for the Windows 9X days.  msconfig is what you want to use now.
  • tasklist (XP pro only)
    Tasklist is the command console equivalent to the task manager in windows. It is a must have when fighting scumware and viruses. Try the command:
    tasklist /svc
    to view the memory resources your services take up.
  • taskkill (XP only)
    Taskkill contains the rest of the task manager functionality.  It allows you to kill those unneeded or locked up applications.
  • tree (XP & 2000)
    An amazing experience everyone should try!  This command will provide a 'family tree' style display of the drive/folder you specify.
  • WMIC (XP & 2000)
    Windows Management Instrumentation Command tool.  This allows you to pull an amazing amount of low-level system information from a command line scripting interface.

a
   ADDUSERS Add or list users to/from a CSV file
   ARP      Address Resolution Protocol
   ASSOC    Change file extension associations•
   ASSOCIAT One step file association
   ATTRIB   Change file attributes
b
   BOOTCFG  Edit Windows boot settings
   BROWSTAT Get domain, browser and PDC info
c
   CACLS    Change file permissions
   CALL     Call one batch program from another•
   CD       Change Directory - move to a specific Folder•
   CHANGE   Change Terminal Server Session properties
   CHKDSK   Check Disk - check and repair disk problems
   CHKNTFS  Check the NTFS file system
   CHOICE   Accept keyboard input to a batch file
   CIPHER   Encrypt or Decrypt files/folders
   CleanMgr Automated cleanup of Temp files, recycle bin
   CLEARMEM Clear memory leaks
   CLIP     Copy STDIN to the Windows clipboard.
   CLS      Clear the screen•
   CLUSTER  Windows Clustering
   CMD      Start a new CMD shell
   COLOR    Change colors of the CMD window•
   COMP     Compare the contents of two files or sets of files
   COMPACT  Compress files or folders on an NTFS partition
   COMPRESS Compress individual files on an NTFS partition
   CON2PRT  Connect or disconnect a Printer
   CONVERT  Convert a FAT drive to NTFS.
   COPY     Copy one or more files to another location•
   CSCcmd   Client-side caching (Offline Files)
   CSVDE    Import or Export Active Directory data
d
   DATE     Display or set the date•
   DEFRAG   Defragment hard drive
   DEL      Delete one or more files•
   DELPROF  Delete NT user profiles
   DELTREE  Delete a folder and all subfolders
   DevCon   Device Manager Command Line Utility
   DIR      Display a list of files and folders•
   DIRUSE   Display disk usage
   DISKCOMP Compare the contents of two floppy disks
   DISKCOPY Copy the contents of one floppy disk to another
   DISKPART Disk Administration
   DNSSTAT  DNS Statistics
   DOSKEY   Edit command line, recall commands, and create macros
   DSACLs   Active Directory ACLs
   DSAdd    Add items to active directory (user group computer)
   DSGet    View items in active directory (user group computer)
   DSQuery  Search for items in active directory (user group computer)
   DSMod    Modify items in active directory (user group computer)
   DSMove   Move an Active directory Object
   DSRM     Remove items from Active Directory
e
   ECHO     Display message on screen•
   ENDLOCAL End localisation of environment changes in a batch file•
   ERASE    Delete one or more files•
   EVENTCREATE Add a message to the Windows event log
   EXIT     Quit the current script/routine and set an errorlevel•
   EXPAND   Uncompress files
   EXTRACT  Uncompress CAB files
f
   FC       Compare two files
   FIND     Search for a text string in a file
   FINDSTR  Search for strings in files
   FOR /F   Loop command: against a set of files•
   FOR /F   Loop command: against the results of another command•
   FOR      Loop command: all options Files, Directory, List•
   FORFILES Batch process multiple files
   FORMAT   Format a disk
   FREEDISK Check free disk space (in bytes)
   FSUTIL   File and Volume utilities
   FTP      File Transfer Protocol
   FTYPE    Display or modify file types used in file extension associations•
g
   GLOBAL   Display membership of global groups
   GOTO     Direct a batch program to jump to a labelled line•
   GPUPDATE Update Group Policy settings
h
   HELP     Online Help
i
   iCACLS   Change file and folder permissions
   IF       Conditionally perform a command•
   IFMEMBER Is the current user in an NT Workgroup
   IPCONFIG Configure IP
k
   KILL     Remove a program from memory
l
   LABEL    Edit a disk label
   LOCAL    Display membership of local groups
   LOGEVENT Write text to the NT event viewer
   LOGOFF   Log a user off
   LOGTIME  Log the date and time in a file
m
   MAPISEND Send email from the command line
   MBSAcli  Baseline Security Analyzer.
   MEM      Display memory usage
   MD       Create new folders•
   MKLINK   Create a symbolic link (linkd)
   MODE     Configure a system device
   MORE     Display output, one screen at a time
   MOUNTVOL Manage a volume mount point
   MOVE     Move files from one folder to another•
   MOVEUSER Move a user from one domain to another
   MSG      Send a message
   MSIEXEC  Microsoft Windows Installer
   MSINFO   Windows NT diagnostics
   MSTSC    Terminal Server Connection (Remote Desktop Protocol)
   MUNGE    Find and Replace text within file(s)
   MV       Copy in-use files
n
   NET      Manage network resources
   NETDOM   Domain Manager
   NETSH    Configure Network Interfaces, Windows Firewall & Remote access
   NETSVC   Command-line Service Controller
   NBTSTAT  Display networking statistics (NetBIOS over TCP/IP)
   NETSTAT  Display networking statistics (TCP/IP)
   NOW      Display the current Date and Time
   NSLOOKUP Name server lookup
   NTBACKUP Backup folders to tape
   NTRIGHTS Edit user account rights
o
   OPENFILES Query or display open files
p
   PATH     Display or set a search path for executable files•
   PATHPING Trace route plus network latency and packet loss
   PAUSE    Suspend processing of a batch file and display a message•
   PERMS    Show permissions for a user
   PERFMON  Performance Monitor
   PING     Test a network connection
   POPD     Restore the previous value of the current directory saved by PUSHD•
   PORTQRY  Display the status of ports and services
   POWERCFG Configure power settings
   PRINT    Print a text file
   PRNCNFG  Display, configure or rename a printer
   PRNMNGR  Add, delete, list printers set the default printer
   PROMPT   Change the command prompt•
   PsExec     Execute process remotely
   PsFile     Show files opened remotely
   PsGetSid   Display the SID of a computer or a user
   PsInfo     List information about a system
   PsKill     Kill processes by name or process ID
   PsList     List detailed information about processes
   PsLoggedOn Who's logged on (locally or via resource sharing)
   PsLogList  Event log records
   PsPasswd   Change account password
   PsService  View and control services
   PsShutdown Shutdown or reboot a computer
   PsSuspend  Suspend processes
   PUSHD    Save and then change the current directory•
q
   QGREP    Search file(s) for lines that match a given pattern.
r
   RASDIAL  Manage RAS connections
   RASPHONE Manage RAS connections
   RECOVER  Recover a damaged file from a defective disk.
   REG      Registry: Read, Set, Export, Delete keys and values
   REGEDIT  Import or export registry settings
   REGSVR32 Register or unregister a DLL
   REGINI   Change Registry Permissions
   REM      Record comments (remarks) in a batch file•
   REN      Rename a file or files•
   REPLACE  Replace or update one file with another
   RD       Delete folder(s)•
   RMTSHARE Share a folder or a printer
   ROBOCOPY Robust File and Folder Copy
   ROUTE    Manipulate network routing tables
   RUNAS    Execute a program under a different user account
   RUNDLL32 Run a DLL command (add/remove print connections)
s
   SC       Service Control
   SCHTASKS Schedule a command to run at a specific time
   SCLIST   Display NT Services
   SET      Display, set, or remove environment variables•
   SETLOCAL Control the visibility of environment variables•
   SETX     Set environment variables permanently
   SFC      System File Checker
   SHARE    List or edit a file share or print share
   SHIFT    Shift the position of replaceable parameters in a batch file•
   SHORTCUT Create a windows shortcut (.LNK file)
   SHOWGRPS List the NT Workgroups a user has joined
   SHOWMBRS List the Users who are members of a Workgroup
   SHUTDOWN Shutdown the computer
   SLEEP    Wait for x seconds
   SLMGR    Software Licensing Management (Vista/2008)
   SOON     Schedule a command to run in the near future
   SORT     Sort input
   START    Start a program or command in a separate window•
   SU       Switch User
   SUBINACL Edit file and folder Permissions, Ownership and Domain
   SUBST    Associate a path with a drive letter
   SYSTEMINFO List system configuration
t
   TASKLIST List running applications and services
   TASKKILL Remove a running process from memory
   TIME     Display or set the system time•
   TIMEOUT  Delay processing of a batch file
   TITLE    Set the window title for a CMD.EXE session•
   TLIST    Task list with full path
   TOUCH    Change file timestamps  
   TRACERT  Trace route to a remote host
   TREE     Graphical display of folder structure
   TYPE     Display the contents of a text file•
u
   USRSTAT  List domain usernames and last login
v
   VER      Display version information•
   VERIFY   Verify that files have been saved•
   VOL      Display a disk label•
w
   WHERE    Locate and display files in a directory tree
   WHOAMI   Output the current UserName and domain
   WINDIFF  Compare the contents of two files or sets of files
   WINMSD   Windows system diagnostics
   WINMSDP  Windows system diagnostics II
   WMIC     WMI Commands
x
   XCACLS   Change file and folder permissions
   XCOPY    Copy files and folders

   ::       Comment / Remark•
Commands marked • are Internal commands only available within the CMD shell.
All other commands (not marked with •) are external commands which may be used under the CMD shell, PowerShell, or directly from START-RUN.


-------------------------------------------------------------------------------------

Start a new CMD shell

Syntax
      CMD [charset] [options] [My_Command]

Options 
   /C     Carries out My_Command and then terminates
   /K     Carries out My_Command but remains

   My_Command : The command, program or batch script to be run.
              This can even be several commands separated with '&'
              (the whole should also be surrounded by "quotes")

   /T:fg  Sets the foreground/background colours
 
   /X     Enable extensions to CMD.EXE
          under Windows 2000 you can also use /E:ON

   /Y     Disable extensions to CMD.EXE
          under Windows 2000 you can also use /E:OFF

   /A     Output ANSI Characters
   /U     Output UNICODE Characters
          These 2 swiches are useful when piping or redirecting to a file
          Most common text files under WinNT are ANSI, use these switches
          when you need to convert the character set.

   /D Ignore registry AutoRun commands
      HKLM | HKCU \Software\Microsoft\Command Processor\AutoRun
 
   /F:ON Enable auto-completion of pathnames entered at the CMD prompt
   /F:OFF Disable auto-completion of pathnames entered at the CMD prompt (default)
At the command prompt Ctrl-D gives folder name completion and Ctrl-F gives File and folder name completion.

These key-strokes will display the first matching path. Thereafter, repeated pressing of the same control key will cycle through the list of matching paths. Pressing SHIFT with the control key will move through the list backwards.

   /Q    Turn echo off

   /S    Strip quote characters from the command_line

   /V:ON Enable delayed environment variable expansion
         this allows a FOR loop to specify !variable! instead of %variable%
         expanding the variable at execution time instead of at input time.
 
   /V:OFF Disable delayed environment expansion.

   Environment expansion preference can be set permanently in the registry
   HKLM | HKCU  \Software\Microsoft\Command Processor\DelayedExpansion
   Set to either 0x1 or 0x0

   /knetdiag /debug
   /knetdiag /fix

   The knetdiag switches are undocumented and work in XP only
   they list and (may) fix these networking issues.

If /C or /K is specified, then the remainder of the command line is
processed as an immediate command in the new shell. Multiple commands
separated by the command separator '&&' are accepted if surrounded by quotes.

The following logic is used to process quote (") characters:

    1.  If all of the following conditions are met, then quote characters
        on the command line are preserved:

        - no /S switch
        - exactly two quote characters
        - no special characters between the two quote characters,
          where special is one of: &<>()@^|
        - there are one or more whitespace characters between the
          the two quote characters
        - the string between the two quote characters is the name
          of an executable file.

    2.  Otherwise, old behavior is to see if the first character is
        a quote character and if so, strip the leading character and
        remove the last quote character on the command line, preserving
        any text after the last quote character.Command.com vs cmd.exe

All the commands on these pages assume you are running the 32 bit command line (cmd.exe)

CMD.exe is the NT/XP equivalent of Command.com in previous operating systems. The older 16 bit command processor command.com is supplied to provide backward compatibility for 16 bit DOS applications. e.g. command.com will fail to set %errorlevel% after certain commands.

To ensure that a batch file will not run if accidentally copied to a Windows 95/98 machine you should use the extension .CMD rather than .BAT

The COMSPEC environment variable will show if you are running CMD.EXE or command.com

On 64 bit versions of windows the 32 bit CMD.exe can be found at %windir%\SysWoW64\cmd.exe To reduce compatibility issues, the WOW64 subsystem isolates 32-bit binaries from 64-bit binaries by redirecting registry calls and some file system calls.

Opening CMD from Windows Explorer

You can open a new CMD prompt by choosing START, RUN, cmd, OK

Registry Keys:

;Allow UNC paths at command prompt
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"DisableUNCCheck"=dword:00000001

; Run a command when CMD.exe starts
[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
"AutoRun"=-

; Activate Automatic Completion
[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]
"CompletionChar"=0x9Previous Commands

Pressing the UP arrow will list previous commands entered at the command prompt.
Other DOSKEY function keys are loaded by default (F7, F8, F9)

Copy and Paste

To simplify the use of cut and paste at the Command Prompt, enable QuickEdit mode as follows:

Activate the control menu at the top left of the current cmd window, go to Properties, Options tab and then tick against QuickEdit Mode.

Now you can select text with the mouse and hit Enter (or right click) to copy it to the clipboard. Paste anywhere using Control+V (or Right Click) or via the menu.

ESC will cancel any selection and return to editing mode.
When copying between windows, you may need one click to select the window and a second click to paste.

Using CMD in a batch script

In a batch script CMD will start a new instance of CMD.exe which will appear in the same window. The EXIT command will close the second CMD instance and return to the previous shell.

A method of calling one Batch script from another is to run a command like

CMD /c C:\docs\myscript.cmd

The output of CMD can be redirected into a text file. Notice that where CMD /c is used, the EXIT command is not required.

The environment Variable %CMDCMDLINE% will expand into the original command line passed to CMD.EXE

Pausing a batch script
Execution of any batch script can be paused by pressing CTRL-S
This also works for pausing a single command such as a DIR listing
Pressing any key will resume the operation.

Stopping a batch script from running
Execution of any batch script can be stopped by pressing CTRL-C

If one batch file CALLs another batch file CTRL-C will exit both batch scripts.
If CMD /c is used to call one batch file from another then CTRL-C will cause only one of the batch scripts to terminate. (see also EXIT)

Long Commands
Under Windows NT, the command line is limited to 256 characters.
Under Windows 2000, the command line is limited to 2046 characters.
Under Windows XP, the command line is limited to 8190 characters.

For all OS's NTFS and FAT allows pathnames of up to 260 characters.

A workaround for the limited pathname length is to prefix \\?\
for example:
\\?\C:\TEMP\Long_Directory\Long_Filename.txt

The above limits are often encountered when using long share names or drag and dropping files onto a batch script.

Full Screen
The key combination ALT and ENTER will switch a CMD window to full screen mode.
press ALT and ENTER again to return to a normal Window.
Command Extensions

Much of the functionality of CMD.exe can be disabled - this will affect all the internal commands, Command Extensions are enabled by default. This is controlled by setting a value in the registry: HKCU\Software\Microsoft\Command Processor\EnableExtensions Alternatively under Win XP you can run CMD /e:on or CMD /e:off

"Those who can command themselves, command others" - Hazlitt

Related:

EXIT - Use this to close a CMD shell and return.
CALL - Call one batch program from another
START - Start a separate window to run a specified program or command
DOSKEY Edit command line, recall commands
Q156276 - Cmd does not support UNC names as the current directory
Powershell: You may run the CMD shell under Powershell, Exit will return you to the PS prompt.
Equivalent bash command (Linux): bash - run the bash shell (also csh, ksh, sh)


--------------------------------------------------------------------------------

Run Commands for Windows XP, Vista and Windows 7:


Accessibility Controls access.cpl
Accessibility Options control access.cpl
Adapter Troubleshooter (Vista/Win7) AdapterTroubleshooter
Add Hardware Wizard hdwwiz.cpl
Add/Remove Programs appwiz.cpl
Add/Remove Programs (Add New Programs) control appwiz.cpl,,1
Add/Remove Programs (Add Remove Windows Components) control appwiz.cpl,,2
Add/Remove Programs (Set Program Access & Defaults ) control appwiz.cpl,,3
Administrative Tools control admintools
Advanced User Accounts Control Panel (Vista/Win7) Netplwiz
Automatic Updates wuaucpl.cpl
Authorization Manager (Vista/Win7) azman.msc

Backup Status and Utility (Vista/Win7) sdclt
Bluetooth Transfer Wizard fsquirt
Calculator calc
Certificate Manager certmgr.msc
Character Map charmap
Check Disk Utility (XP) chkdsk
Clipboard Viewer clipbrd
Color Management colorcpl
Command Prompt cmd
Component Services dcomcnfg
Computer Management (XP) compmgmt.msc
Computer Management (Vista/Win7) CompMgmtLauncher
Control Panel control
Credential (passwords) Backup and Restore Wizard (Vista/Win7) credwiz

Date and Time Properties timedate.cpl
Device Manager devmgmt.msc
Direct X Control Panel* directx.cpl
Direct X Troubleshooter dxdiag
Disk Cleanup Utility cleanmgr
Disk Defragmenter (XP) dfrg.msc
Disk Defragmenter (Vista) dfrgui
Disk Defragmenter defrag
Disk Management diskmgmt.msc
Disk Partition Manager diskpart
Display Properties control desktop
Display Properties desk.cpl
Display Properties (Appearance) control color
Dr. Watson System Troubleshooting Utility drwtsn32
Driver Verifier Utility verifier
Driver Package Installer (Vista/Win7) dpinst
DVD Player dvdplay

Event Viewer eventvwr.msc
File Signature Verification Tool sigverif
Files and Settings Transfer Tool migwiz
Findfast findfast.cpl
Firewall Control Panel (Vista/Win7) FirewallControlPanel
Firewall Settings (Vista/Win7) FirewallSettings
Folders Properties control folders
Fonts control fonts
Fonts Folder fonts

Game Controllers joy.cpl
Group Policy Editor (XP Prof) gpedit.msc

IExpress - Turn a cmd/vbs script into an installer .exe file C:\Windows\System32\iexpress.exe (example)
Indexing Service ciadv.msc
Internet Properties inetcpl.cpl
IP Configuration ipconfig
iSCSI Initiator (Vista/Win7) iscsicpl

Keyboard Properties control keyboard

Language Pack Installer (Vista/Win7) lpksetup
Local Security Policy secpol.msc
Local Users and Groups (XP) lusrmgr.msc
Log out logoff

Microsoft Access* msaccess
Microsoft Excel* excel
Microsoft Malicious Software Removal Tool mrt
Microsoft Paint mspaint
Microsoft Powerpoint* powerpnt
Microsoft Support Diagnostic Tool (Vista/Win7) msdt
Microsoft Word* winword
Mouse Properties control mouse
Mouse Properties main.cpl
MSN Messenger* msnmsgr

Network Connections control netconnections
Network Connections ncpa.cpl
Network Setup Wizard netsetup.cpl
Notepad notepad

ODBC Data Source Administrator odbccp32.cpl
On Screen Keyboard osk

Paint pbrush
Password Properties password.cpl
Performance Monitor perfmon.msc
Phone and Modem Options telephon.cpl
Phone Dialer dialer
Power Configuration powercfg.cpl
Printers and Faxes control printers
Printers Folder printers
Private Character Editor eudcedit

Quicktime* QuickTime.cpl
Quicktime Player* quicktimeplayer
Regional Settings intl.cpl
Registry Editor regedit
Registry Editor regedit32
Reliability and Performance Monitor perfmon.msc
Remote Assistance(Vista/Win7) msra
Remote Desktop mstsc
Removable Storage ntmsmgr.msc
Removable Storage Operator Requests ntmsoprq.msc
Resultant Set of Policy (XP Prof) rsop.msc

Scanners and Cameras sticpl.cpl
Scheduled Tasks control schedtasks
Security Center wscui.cpl
Services services.msc
Shared Creation Wizard shrpubw
Shared Folders fsmgmt.msc
Shut Down Windows shutdown
Software Licensing/Activation (Vista/Win7) slui
Sounds and Audio mmsys.cpl
Sound Recorder (Vista/Win7) soundrecorder
Sound Volume (Vista/Win7) sndvol
SQL Client Configuration cliconfg
Sync Center mobsync
Syncronization Tool mobsync
System Configuration Editor sysedit
System Configuration Utility msconfig
System File Checker Utility (Scan/Purge) sfc
System Information msinfo32
System Properties sysdm.cpl
System Properties (Vista/Win7) SystemPropertiesAdvanced, SystemPropertiesComputerName,
SystemPropertiesDataExecutionPrevention,SystemPropertiesHardware,
SystemPropertiesPerformance,SystemPropertiesProtection, SystemPropertiesRemote

Task Manager taskmgr
Telnet Client telnet
Trusted Platform Module Initialization Wizard (Vista/Win7) TpmInit
Tweak UI* tweakui
User Account Management nusrmgr.cpl
User Accounts (Autologon) control userpasswords2
Utility Manager utilman

Windows Error Reports wercon
Windows Features (Vista/Win7) optionalfeatures
Windows Firewall firewall.cpl
Windows Firewall with Advanced Security (Vista/Win7) wf.msc
Windows Image Acquisition (scanner)(Vista/Win7) wiaacmgr
Windows Magnifier magnify
Windows Management Infrastructure wmimgmt.msc
Windows Mobility Center (Mobile PCs only)(Vista/Win7) mblctr
Windows Security Center wscui.cpl
Windows System Security Tool syskey
Windows Update wupdmgr
Windows Update (Vista/Win7) wuapp
Windows Update Standalone Installer(Vista/Win7) wusa
Windows XP Tour Wizard tourstart
Windows Version (About Windows) winver
Wordpad write

* = optional component that may not be installed on all machines.

--------------------------------------------------------------------------------------

SHUTDOWN.exe (for Terminal Services use: TsShutDn)

Shutdown the computer

Syntax

      SHUTDOWN [logoff_option]  [/m \\Computer] [options]

logoff_option:
    /i         Display the GUI (must be the first option)    /l         Log off. This cannot be used with /m or /d option    /s         Shutdown    /r         Shutdown and Restart    /a         Abort a system shutdown.               (only during the time-out period)
    /p         Turn off the local computer with no time-out or warning               (only with /d)    /h         Hibernate the local computer (only with /f )    /e         Document the reason for an unexpected shutdown of a computer

Options:
   /m \\Computer  : A remote computer to shutdown.

   /t:xxx         : Time until system shutdown in seconds.                     The valid range is xxx=0-600 seconds. [default=30]
   /c "Msg"       : An optional shutdown message [Max 127 chars]

   /f             : Force running applications to close.
                    This will not prompt for File-Save in any open applications.
                    so will result in a loss of all unsaved data!!!

   /d u:xx:yy     : List a USER reason code for the shutdown.
   /d P:xx:yy     : List a PLANNED reason code for the shutdown.
                     xx Specifies the major reason code (0-255)
                     yy Specifies the minor reason code (0-65536)

Options in bold are for Windows 2003 onlyExample:

To create a desktop shortcut that will immediately shutdown your system, set the shortcut Target Properties to:
C:\Windows\System32\shutdown.exe -s

When using this command to reboot a server, the shutdown process will normally allow about 30 seconds to ensure each running service has time to stop. The shutdown can be made faster if all the services are first halted using NET STOP

e.g.
net stop "Microsoft Exchange Internet Mail Service"
net stop "Microsoft FTP Service"
net stop "Some other Service"
SHUTDOWN /t:25 /r
Typical Reason codes:
E = Expected
 U = Unexpected
   P = planned (C = customer defined)

Type    Major Minor Title
 U      0     0   Other (Unplanned)
E       0     0   Other (Unplanned)
E P     0     0   Other (Planned)
 U      0     5   Other Failure: System Unresponsive
E       1     1   Hardware: Maintenance (Unplanned)
E P     1     1   Hardware: Maintenance (Planned)
E       1     2   Hardware: Installation (Unplanned)
E P     1     2   Hardware: Installation (Planned)
  P     2     3   Operating System: Upgrade (Planned)
E       2     4   Operating System: Reconfiguration (Unplanned)
E P     2     4   Operating System: Reconfiguration (Planned)
  P     2     16  Operating System: Service pack (Planned)
        2     17  Operating System: Hot fix (Unplanned)
  P     2     17  Operating System: Hot fix (Planned)
        2     18  Operating System: Security fix (Unplanned)
  P     2     18  Operating System: Security fix (Planned)
E       4     1   Application: Maintenance (Unplanned)
E P     4     1   Application: Maintenance (Planned)
E P     4     2   Application: Installation (Planned)
E       4     5   Application: Unresponsive
E       4     6   Application: Unstable
 U      5     15  System Failure: Stop error
E       5     19  Security issue
 U      5     19  Security issue
E P     5     19  Security issue
E       5     20  Loss of network connectivity (Unplanned)
 U      6     11  Power Failure: Cord Unplugged
 U      6     12  Power Failure: Environment
  P     7     0   Legacy API shutdown

e.g. SHUTDOWN /r /d P:2:17"I shall go the way of the open sea, To the lands I knew before you came,
And the cool ocean breezes shall blow from me, The memory of your name" - Laurence Hope

Related:

LOGOFF - Log off a user.
BootCFG - Edit Boot.ini settings.
PsShutdown - SysInternals command line tool
TsShutDn - Terminal Services Shutdown
PowerOff - Stefan Kuhr utility (NT / 2K)
JSIFAQ Tip 9130 - log off user after n minutes of inactivity
Powershell:
$os = (Get-WmiObject Win32_OperatingSystem -ComputerName MyServer64)
$os.psbase.Scope.Options.EnablePrivileges = $true
$os.reboot()

---------------------------------------------------------------------------------

CD
Change Directory - Select a Folder (and drive)

Syntax
      CD [/D] [drive:][path]
      CD [..]

Key
   /D : change the current DRIVE in addition to changing folder.   Examples

   To change to the parent directory.
   C:\Work> CD ..
 
   To change to the grant-parent directory.
   C:\Work\backup\January> CD ..\..
 
   To change to the ROOT directory.
   C:\Work\backup\January> CD \
 
   To display the current directory in the specified drive.
   C:\>  CD D:
 
   To display the current drive and directory.
   C:\Work> CD

   To display the current drive and directory.
   C:\Work> ECHO "%CD%"

   In a batch file to display the location of the batch script file (%0)
   C:\> ECHO "%~dp0"

   Moving down the folder tree with a full path reference to the ROOT folder...
   C:\windows> CD \windows\java
   C:\windows\java>
 
   Moving down the folder tree with a reference RELATIVE to the current folder...
   C:\windows> CD java
   C:\windows\java>
 
   Moving up and down the folder tree in one command...
   C:\windows\java> CD ..\system32
   C:\windows\system32>If Command Extensions are enabled the CD command is enhanced as follows:

1) The current directory string is converted to use the correct CASE.
So CD C:\wiNnt would actually set the current directory to C:\Winnt

2) CD does not treat spaces as delimiters, so it is possible to CD into a subfolder name that contains a space without surrounding the name with quotes.

For example:
cd \My folder

is the same as:
cd "\My folder"

3) An asterisk can be used to complete a folder name
e.g. from C:\

C:> CD pro*
will move to
C:\Program Files

CHDIR is a synonym for CD

Tab Completion

This allows changing current folder by entering part of the path and pressing TAB

   C:> CD Prog [PRESS TAB]
   Will go to C:\Program Files\Tab Completion is disabled by default, it has been known to create difficulty when using a batch script to process text files that contain TAB characters.

Tab Completion is turned on by setting the registry value shown below

REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"CompletionChar"=dword:00000009

Changing the Current drive

simply enter the drive letter followed by a colon
C:> E:
E:>

To change drive and directory at the same time, use CD with the /D switch
C:> cd /D E:\utils
E:\utils\>

"Change is the law of life. And those who look only to the past or the present are certain to miss the future" - John F. Kennedy

Related:

You can also change directory using the pushd command
Q156276 - Cmd does not support UNC names as the current directory
JSIFaq Tip 4757 - cd Folder navigation
Powershell: Set-Location - Set the current working location
Equivalent bash command (Linux): cd - Change Directory


-----------------------------------------------------------------------------------

DEL

Delete one or more files.

Syntax
      DEL [options] [/A:file_attributes] files_to_delete
Key
   files_to_delete : This may be a filename, a list of files or a Wildcard options
   /P  Give a Yes/No Prompt before deleting.
   /F  Ignore read-only setting and delete anyway (FORCE)
   /S  Delete from all Subfolders (DELTREE)
   /Q  Quiet mode, do not give a Yes/No Prompt before deleting.

   /A  Select files to delete based on file_attributes
file_attributes:
   R  Read-only    -R  NOT Read-only
   S  System       -S  NOT System
   H  Hidden       -H  NOT Hidden
   A  Archive      -A  NOT ArchiveWildcards: These can be combined with part of a filename   *  Match any characters   ?  Match any ONE characterExamples:

To delete HelloWorld.TXT
DEL HelloWorld.TXT

To delete "Hello Big World.TXT"
DEL "Hello Big World.TXT"

To delete all files that start with the letter A
DEL A*

To delete all files that end with the letter A
DEL *A.*

To delete all files with a .DOC extension
DEL *.DOC

To delete all read only files
DEL /a:R *

To delete all files including any that are read only
DEL /F *

Folders
If a folder name is given instead of a file, all files in the folder will be deleted, but the folder itself will not be removed.

Temporary Files
You should clear out TEMP files on a regular basis - this is best done at startup when no applications are running. To delete all files in all subfolders of C:\temp\ but leave the folder structure intact:

   DEL /F /S /Q %TEMP%When clearing out the TEMP directory it is not generally worthwhile removing the subfolders too - they don't use much space and constantly deleting and recreating them can potentially increase fragmentation within the Master File Table.

Deleting a file will not prevent third party utilities from un-deleting it again, however you can turn any file into a zero-byte file to destroy the file allocation chain like this:

TYPE nul > C:\examples\MyFile.txt
DEL C:\examples\MyFile.txt

Undeletable Files

Files are sometimes created with the very long filenames or reserved names: CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN, NUL
To delete these use the syntax: DEL \\.\C:\somedir\LPT1
Alternatively SUBST a drive letter to the folder containing the file.

If a file (or folder) still appears to be 'undeletable' this is often caused by the indexing service.
Right click the file you need to delete, choose properties, advanced and untick "allow indexing" you will then be able to delete the file.
To cure the problem permanently - Control Panel, Add/Remove programs, Win Accessories, indexing service.

Delete Locked files (Typically IE temp files or the Offline cache)
This works on any version of NT, 2000 or XP

Close all applications
Open a command prompt
Click Start, and then Shut Down
Simultaneously press CTRL+SHIFT+ALT.
While you keep these keys pressed, click Cancel in the Shut Down Windows dialog box.
In the command prompt window, navigate to the cache location, and delete all files from the folder (DEL /s)
At the command prompt, type explorer, and then press ENTER.

DELTREE

Previous versions of Windows had the DELTREE command that deletes all files and sub folders.
DEL /s will delete all files
RD /s will remove all files and folders including the root folder.

:: Remove all files and subfolders but NOT the root folder
:: From tip 617 at JsiFAQ.com
@echo off
pushd %1
del /q *.*
for /f "Tokens=*" %%G in ('dir /B') do rd /s /q "%%G"
popd Normally DEL will display a list of the files deleted, if Command Extensions are disabled; it will instead display a list of any files it cannot find.

ERASE is a synonym for DEL

-----------------------------------------------------------------------------

COPY

Copy one or more files to another location

Syntax      COPY source destination [options]

      COPY source1 + source2.. destination [options]Key
     source :  Pathname for the file or files to be copied.
        /A  :  ASCII text file (default)
        /B  :  Binary file copy - will copy extended characters.
destination :  Pathname for the new file(s).
        /V  :  Verify that the new files were written correctly.
        /N  :  If at all possible, use only a short filename (8.3) when creating
               a destination file. This may be necessary when copying between disks
               that are formatted differently e.g NTFS and VFAT, or when archiving
               data to an ISO9660 CDROM.        /Z  :  Copy files in restartable mode. If the copy is interrupted                part way through, it will restart if possible. (use on slow networks)

        /Y  :  Suppress confirmation prompt (Windows 2000 only)

        /-Y :  Enable confirmation prompt (Windows 2000 only)
Prompt to overwrite destination file

NT 4 will overwrite destination files without any prompt, Windows 2000 and above will prompt unless the COPY command is being executed from within a batch script.
To force the overwriting of destination files under both NT4 and Windows2000 use the COPYCMD environment variable:

SET COPYCMD=/Y

This will turn off the prompt in Win2000 and will be ignored by NT4 (which overwrites by default)

Binary copies
"COPY /B ... " will copy all the files in binary mode , you can also put /B after any one file to copy just that file in binary.

Combine files
To combine files, specify a single file for the destination, but multiple files as the source. To specify more than one file use wildcards or list the files with a + in between each (file1+file2+file3)
When copying multiple files in this way the first file must exist or else the copy will fail, a workaround for this is COPY null + file1 + file2 dest1

COPY will accept UNC pathnames

Copy from the console (accept user input)

COPY CON filename.txt
Then type the input text followed by ^Z (Control key & Z)

To do this in Powershell use the following function:

function copycon {
[system.console]::in.readtoend()
}

Examples:

In the current folder
COPY oldfile.doc newfile.doc

Copy from a different folder/directory:
COPY "C:\my work\some file.doc" "D:\New docs\newfile.doc"

Specify the source only, with a wildcard will copy all the files into the current directory:
COPY "C:\my work\*.doc"

Specify the source with a wildcard and the destination as a single file, this is generally only useful with plain text files.
COPY "C:\my work\*.txt" "D:\New docs\combined.txt"

Quiet copy (no feedback on screen)
COPY oldfile.doc newfile.doc >nul

"Success seems to be connected with action. Successful men keep moving. They make mistakes, but they don't quit"

--------------------------------------------------------------------------------

FOR /F

Loop command: against a set of files - conditionally perform a command against each item.

Syntax
        FOR /F ["options"] %%parameter IN (filenameset) DO command
    
        FOR /F ["options"] %%parameter IN ("Text string to process") DO command
      
Key 
   options:
      delims=xxx   The delimiter character(s) (default = a space)

      skip=n       A number of lines to skip at the beginning of the file.
                    (default = 0)

      eol=;        Character at the start of each line to indicate a comment
                   The default is a semicolon ;

      tokens=n     Specifies which numbered items to read from each line
                  (default = 1)
        
      usebackq     Specify `back quotes`:                      
                   - Use double quotes to quote long file names in filenameset.
                   - Use single quotes for 'Text string to process'
                     (useful if the text string contains double quotes)

   Filenameset    A set of one or more files. Wildcards may be used.
                  If (filenameset) is a period character (.) then FOR will
                  loop through every file in the folder.
   command        The command to carry out, including any                
                  command-line parameters.
 
   %%parameter    A replaceable parameter:             
                  in a batch file use %%G (on the command line %G)FOR /F processing of a text file consists of reading the file, one line of text at a time and then breaking the line up into individual items of data called 'tokens'. The DO command is then executed with the parameter(s) set to the token(s) found.

By default, /F breaks up the line at each blank space " ", and any blank lines are skipped, this default parsing behavior can be changed by applying one or more of the "options" parameters. The option(s) must be contained within "a pair of quotes"

Within a FOR loop the visibility of FOR variables is controlled via SETLOCAL EnableDelayedExpansion

Tokens
tokens=2,4,6 will cause the second, fourth and sixth items on each line to be processed

tokens=2-6 will cause the second, third, fourth, fifth and sixth items on each line to be processed

tokens=* will cause all items on each line to be processed

tokens=3* will cause the 3rd and all subsequent items on each line to be processed

Each token specified will cause a corresponding parameter letter to be allocated.

If the last character in the tokens= string is an asterisk, then additional parameters are allocated for all the remaining text on the line.

Delims
More than one delimiter may be specified so a string like 'abcd+efg+hijk+lmno;pqr;stu+vwzyz' can be broken up using "delims=;+".

You can use any character as a delimiter, but they are case sensitive.
If you don't specify delims it will default to "delims=<tab><space>"

n.b. some text editors will enter the TAB character as a series of spaces, specifying more than one delimiter has been known to cause problems with some data sets.

usebackq
This option is useful when dealing with a filenameset that is a long filename containing spaces, it allows you to put double quotes around the filename.
The backquote character ` is just below the ESC key on most keyboards.

eol
The default end-of-line character is a semicolon ';' when the FOR command reads a text file (or even a character string), any line that STARTS with the eol character will be ignored. In other words it is treated as a comment.
Use eol=X to change the eol character to X.
Most often you will want to turn this feature off so that every line of your data file is processed, in theory "eol=" should turn this feature off, but in practice this fails to work correctly so instead set eol to some unusual character that you don't expect to ever be in the data file e.g. "eol=€" or "eol=¬".

Examples

Extracting data from this text file:

January,Snowy,02
February,Rainy,15
March,Sunny,25

FOR /F "tokens=1,3 delims=," %%G IN (weather.txt) DO @echo %%G %%H

The tricky part is splitting up each the line into the right tokens, in this case I'm splitting on the comma character ',' this splits the line into 3 chunks of text and we pull out the first and third items with "tokens=1,3"
 ______________________________
|token1 , | token2 ,  | token3 |
|%%G      | <ignored> | %%H    |
|January  |           | 02     |
|February |           | 15     |
|March    |           | 25     |
|_________|___________|________|

%%G is declared in the FOR statement and %%H is implicitly declared via the tokens= option. You can specify up to 26 tokens via the tokens= line, provided this does not cause an attempt to declare a parameter higher than the letter 'Z'.

FOR parameter names are global, so in complex scripts which call one FOR statement from within another FOR statement you can refer to both sets of parameters. You cannot have more than 26 parameters active at any one time.

Parse a text string:
A string of text will be treated just like a single line of input from a file, the string must be enclosed in double quotes (or single quotes with usebackq).

Echo just the date from the following string

FOR /F "tokens=4 delims=," %%G IN ("deposit,$4500,123.4,12-AUG-09") DO @echo Date paid %%G

Parse the output of a command:

FOR /F %%G IN ('"C:\program Files\command.exe"') DO ECHO %%G

Parse the contents of a file:

FOR /F "tokens=1,2* delims=," %%G IN (C:\MyDocu~1\mytex~1.txt) DO ECHO %%G

FOR /F "usebackq tokens=1,2* delims=," %%G IN ("C:\My Documents\my textfile.txt") DO ECHO %%G

Filenameset

To specify an exact set of files to be processed, such as all .MP3 files in a folder including subfolders and sorted by date - just use the DIR /b command to create the list of filenames ~ and use this variant of the FOR command syntax.

Unicode

Many of the newer commands and utilities (e.g. WMIC) output text files in unicode format, these cannot be read by the FOR command which expects ASCII.
To convert the file format use the TYPE command.

"It's completely intuitive; it just takes a few days to learn, but then it's completely intuitive"

------------------------------------------------------------------------------------

- Shifat