280
votes

The aim for this Wiki is to promote using a command to open up commonly used applications without having to go through many mouse clicks - thus saving time on monitoring and troubleshooting Windows machines.

Answer entries need to specify

  • Application name
  • Commands
  • Screenshot (Optional)

Shortcut to commands

6
  • 11
    If you find this stuff interesting, take a look at commandlinefu: commandlinefu.com It's basically like digg for CLI
    – username
    May 11, 2009 at 6:47
  • great list, very usefull
    – Adyt
    May 20, 2009 at 8:56
  • 1
    Try putting each command as a separate answer. Then we can vote and comment on each one.
    – lamcro
    Jun 26, 2009 at 12:22
  • 1
    This is a great question, super useful info, and the stackexchange engine made it trivial to find. I agree with @lamcro, however, that structuring each command as an individual answer would likely provide more value, however then the wouldn't be sorted alphabetically? hmmm... Jul 29, 2009 at 22:00
  • 1
    This is a great example, across all SE, of a well-executed poll. I especially like combining separate answers (for voting) and alphabetical index to them!
    – Jonik
    Sep 17, 2010 at 14:16

160 Answers 160

1
2 3 4 5 6
120
votes

A little known one is

getmac

It shows the MAC address(es) of your network adapter(s).

Screenshot of running getmac from a Windows commandline window.

4
  • Very nice. When I run this on my laptop I get "ERROR: Not found.", however I can run getmac /? and it prints out the description / usage... ideas?
    – Zack Mulgrew
    May 6, 2009 at 16:39
  • 5
    ipconfig /all gives you this information in a less direct way too. May 11, 2009 at 6:56
  • Ha, now I've got your MAC address, prepare to be hackzored! May 15, 2009 at 22:02
  • 2
    THANK YOU! No more ipconfig /all and scrolling around! "Happy dance!"
    – Gomibushi
    Mar 24, 2010 at 20:41
65
votes

In the command prompt type:

C:\> start .

It opens the current directory in the Windows Explorer.

7
  • 2
    How neat. it works just like "ii ." in powershell.
    – dance2die
    May 4, 2009 at 15:34
  • start . & exit is also good - I've got those set as s.cmd and sx.cmd respectively. Also x.cmd for exit, because yes I'm that lazy.
    – Mark Allen
    May 5, 2009 at 21:01
  • 5
    You could also do "explorer ." May 9, 2009 at 17:14
  • 2
    start actually works for any file type you can double-click on (word documents, xls files, etc) as well as drive mappings (not just the current working directory). May 27, 2009 at 16:40
  • 5
    Note that start can be a bit funny if you have files with spaces in their names. If start's first argument is quoted, it interprets it as a request to change the window title. So instead of running: start "My File.txt" you have to enter: start "" "My File.txt" This drove me nuts until someone explained it to me!
    – Ken Keenan
    Jun 28, 2009 at 20:39
50
votes
Remote Desktop Connection
mstsc.exe

Opens:

Some image demonstrationg the use of mstsc.exe.

12
  • 16
    Even better with the /v: switch. Just Win+R, then "mstsc /v:computer.fabrikam.com"
    – Portman
    May 4, 2009 at 3:31
  • 9
    renamed to /admin switch these days, and behaves quite differently in 2008+ May 4, 2009 at 10:04
  • 17
    don't forget the /span option for creating really big sessions across two monitors.
    – SqlACID
    May 4, 2009 at 14:35
  • 6
    Renamed back to /console in Vista SP1 and later, because they shouldn't have changed it in the first place. :)
    – Mark Allen
    May 5, 2009 at 21:00
  • 7
    While we're at it, I also often use /w: and /h: to manually set width and height. I'm particularly fond of running IIS Manager in 800x800 for some reason.
    – Portman
    May 6, 2009 at 0:08
45
votes

A list I use a lot:

  • nbtstat - List NetBIOS stats and information
  • netstat - List TCP/IP stats and information
  • ipconfig - List TCP/IP configuration for a system
  • netsh - Network configuration for a system
  • sc - manage services
  • net - whole slew of commands to manage users and groups, shares, connections, etc.
  • ping - makes sure a system is up on the network
  • tracert - trace the hops between two hosts. useful to see if there's a break in between and where it is.
  • nslookup - Query DNS for information
  • dcdiag - check health of the domain controller
  • setspn - check SPNs for Kerberos configuration
3
  • sorry, what is the use of "sc"?
    – Alex. S.
    May 9, 2009 at 5:26
  • 1
    sc allows you to control services, and it allows you to do so remotely. This is different from net start/net stop, which run locally (albeit you can use psexec or something like that to get to a console on a remote system). sc will also query the service, etc. Basically everything you can do from services.msc you can now do from the command-line. technet.microsoft.com/en-us/library/cc754599.aspx May 9, 2009 at 11:23
  • 1
    netsh seems like a really powerful command, but I have not really been able to work with it. What do people really use it for?
    – railmeat
    Aug 11, 2009 at 2:33
43
votes

Services control panel:

services.msc
3
  • find myself using this alot
    – Adyt
    May 20, 2009 at 8:58
  • You can also type this (and the names of other MMC snap-ins) into the Run dialog. services.msc and compmgmt.msc are my most commonly used entries.
    – Coxy
    Aug 11, 2009 at 6:57
  • You can use SC to manager services from the command prompt. Of course the venerable net command can start and stop services.
    – railmeat
    May 2, 2010 at 2:09
41
votes
shutdown.exe

allow you to shutdown or reboot a machine. You can even reboot a remote machine with

shutdown -m \\server -t 0 -r

It even comes with a graphical user interface

shutdown -i

and you can abort a shutdown with

shutdown -a
4
  • Ouch, I don't think I will be trying this out often unless I do it on a VM ;)
    – dance2die
    May 5, 2009 at 20:56
  • I use this at the end of my end-of-week script.
    – mmyers
    May 15, 2009 at 21:09
  • This one's essential for us. We're an app group and our IT's centrally located out-of-state. We have local admin access to all of our servers and can reboot at will. It's not unusual for TS to choke when trying to shutdown and this is the only thing that we can use to kick things back into shape without calling an operator.
    – squillman
    May 31, 2009 at 4:08
  • give it a -f as well to force all open apps to close
    – beakersoft
    Dec 17, 2010 at 14:30
37
votes

Robocopy is really useful. It mirrors directories.

It is great for backups, restoring, and transferring large amounts of files. It only transfers files which have changed and can resume from where it left off.

It comes standard in Windows Vista and later, but Windows XP users can get it as part of the Windows Server 2003 Resource Kit (free) or later.

6
  • Robocopy does so much more than mirror directories. It's freeking amazing! Any command-line tool that requires a word document to explain it rocks in my book.
    – WaldenL
    May 5, 2009 at 19:25
  • 1
    hehe. Well I guess it's a swiss-army-knife of command line copying, but with no GUI nonsense. May 6, 2009 at 1:33
  • +1; Robocopy, tar, split and gzip form basically all of our backup strategy.
    – RainyRat
    Jun 21, 2009 at 0:21
  • @RainyRat: What, no 'at' command? Sep 13, 2009 at 4:21
  • Is this the rsync of Windows?
    – Joey Adams
    Jul 30, 2011 at 6:11
34
votes

(Not really a command per-se, but a way to get there.)

For those of you that find yourself going to Start > Run > "cmd" a lot, you can cut down some steps.

Say you want to get your IP address. You would normally go Start > Run > "cmd" [enter] then...

ipconfig [enter]

Now instead, go...

Start > Run > "cmd /k ipconfig"

This will run cmd and the command 'ipconfig', and it will keep the window open. So if I want to quickly get my MAC address (physical address), I'd do:

 cmd /k ipconfig /all

...all from the run menu in one line.


All courtesy of BostonMark

5
  • Very cool, I am constantly doing Start>Run>Cmd to run various common commands and didn't know this shortcut.
    – Element
    May 9, 2009 at 6:09
  • 3
    Yes, the /k flag is definitely one of the best tips here. May 17, 2009 at 2:26
  • 10
    Here's a better way: Go to START > All Programs > Accessories > Command Prompt, and right-click. Select Properties. Click the 'Short-cut' tab. Put the cursor in the 'Shortcut Key' field. Press [ctrl]-[alt]-t, it should say "Ctrl+Alt+T". Click OK. Now you can launch cmd.exe from anywhere anytime by hitting ctrl-alt-t. Jun 2, 2009 at 21:25
  • 5
    Also, using windowskey+r gets you directly to the "Run..." window.
    – Andor
    Mar 16, 2010 at 18:32
  • 1
    How is this quicker or fewer keystrokes than opening cmd and typing the command? Seems to me two more keystrokes than the way you're proposing to replace.
    – harpo
    Oct 3, 2010 at 5:27
28
votes

The forgotten art: DOS String Manipulation!

set mydate=%date:~10,4%_%date:~4,2%_%date:~7,2%
echo %mydate%

Output will be YYYY_MM_DD.

Copy and paste this into a .bat file and be amazed! This is especially useful for creating backups, or any time/date series of directories and files.

An example:

@echo off
:: Yes, this looks bad, but it works, it sets the file veriable mydate to YYYY_MM_DD.
set mydate=%date:~10,4%_%date:~4,2%_%date:~7,2%

echo Backing up DC1:
:: start a new backup session, the /M switch is for the type of bakcup being performed, type ntbackup /? for more info
start /wait ntbackup backup \\DC1\c$ /j "DC1 Backup" /f "C:\BAK\DC1\DC1_%mydate%.bkf" /M incremental
echo DC1 is Done

echo Backing up EXCH:
start /wait ntbackup backup \\EXCH\c$ /j "EXCH Backup" /f "C:\BAK\EXCH\EXCH_%mydate%.bkf" /M incremental
echo EXCH is Done

echo Backing up FS1:
start /wait ntbackup backup \\FS1\c$ /j "FS1 Backup" /f "C:\BAK\FS1\FS1_%mydate%.bkf" /M incremental
echo FS1 is Done

echo Backup was completed %date% %time%
pause
2
  • 5
    This is dangerous as hell as the system locale display format changes the string that date returns and hence will thrash any script based on character position into an unpredictable mess if it ever changes. Which at least in Europe can easily happen by mistake or on purpose - I've had scheduled batch scripts do horrible things (or nothing) because of exactly this ^^ Jun 13, 2010 at 11:23
  • Well ... I would hope that people wouldn't copy/paste/pray on production systems ... :-) Good point though. Jan 25, 2011 at 0:42
26
votes
tasklist.exe

will list processes on local or a remote machine.

tasklist.exe /S server

It can display which Services the scvhost.exe processes are hosting with

tasklist /SVC

You can also do some filtering. This will display the processes on a remote machine that have used more than 15 minutes of CPU time

tasklist /S server /FI "CPUTIME gt 00:15:00"
1
  • 1
    Don't forget it's counterpart taskkill
    – Chris S
    Jul 8, 2010 at 3:39
25
votes

control userpasswords2

Opens the classic User Accounts dialog:

enter image description here

0
24
votes

I find that I use findstr a lot to find stuff in logs, error files, etc.

A simple example: in the log file ex0905.log we find all lines that have 2009-05-05 in them:

findstr "2009-05-05" ex0905.log
2
  • 1
    findstr /s find recursively
    – Alex. S.
    May 9, 2009 at 5:30
  • Put @findstr %* into a file named fs.bat in the PATH.
    – Lumi
    Dec 2, 2011 at 19:57
22
votes
Programs and Features (Formerly known as "Add or Remove Programs")
appwiz.cpl

Opens

alt text

3
  • Windows, then "fea" also isolates it well.. (But +1) May 28, 2009 at 13:41
  • @Farseeker: I ran out of my 80G space as I was taking screenshot. Coudln't even spare a couple of megs at the time ;)
    – dance2die
    Oct 13, 2009 at 0:19
  • You often need to do control appwiz.cpl - especially if you're doing it under runas (as you probably should be!) Aug 27, 2010 at 15:56
21
votes

Sometimes I have to worry about too few free sessions for a Terminal Server connection to a server.

quser displays information about user sessions on a terminal server.

quser /SERVER:myserver

Output

C:\Documents and Settings\sysmanager01>quser /SERVER:serverx
USERNAME                    SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
usr_hot1                                        1  Disc        none   30.04.2009 17:59
usr_hot                                         2  Disc        none   30.04.2009 18:01
appsuperuser                rdp-tcp#6           3  Conn            .  01.01.1601 02:00

Sometimes it's even possible to find pure workaholics like appsuperuser :-)

It's easier when pasting the quser executable from any 32-bit Server to my local System32 folder.

2
  • What version of Windows is "quser" available?
    – dance2die
    May 4, 2009 at 18:33
  • 6
    Try using qwinsta instead, it's included by default in clients like XP as well... rwinsta can nuke the sessions May 7, 2009 at 13:43
17
votes

I use

qwinsta

to see disconnected remote desktop sessions and

logoff

to end them.

It works on Windows 2000, Windows XP, Windows Vista, Windows Server 2003 and probably Windows Server 2008 (never tried).

2
  • you can use rwinsta to boot the remote session by id too! May 27, 2009 at 14:06
  • thats incredible. im impressed.
    – djangofan
    Jul 6, 2010 at 21:05
16
votes
systeminfo

Displays a ton of information about the system at hand. The following are what it outputs on Vista:

  • Host Name
  • OS Name
  • OS Version
  • OS Manufacturer
  • OS Configuration
  • OS Build Type
  • Registered Owner
  • Registered Organization
  • Product ID
  • Original Install Date
  • System Boot Time
  • System Manufacturer
  • System Model
  • System Type
  • Processor(s)
  • BIOS Version
  • Windows Directory
  • System Directory
  • Boot Device
  • System Locale
  • Input Locale
  • Time Zone
  • Total Physical Memory
  • Available Physical Memory
  • Page File
  • Max Size
  • Page File
  • Available
  • Page File
  • In Use
  • Page File Location(s)
  • Domain
  • Logon Server
  • Hotfix(s)
  • Network Card(s)
1
  • this is really useful. did not know this one
    – MikeJ
    Aug 10, 2009 at 20:46
16
votes
Computer Management
compmgmt.msc

Opens
enter image description here

15
votes

Very useful one I only found out about recently:

winver.exe

Gives you a dialog box with the version of Windows the machine is running, complete with Service Pack level and build number.

1
  • 9
    Note that I use the hotkey Win+Pause to see most of this information quickly on a box.
    – Matthew
    May 27, 2009 at 20:29
14
votes

There is still no mention of WMIC.exe :)

Find whatever you want from remote machine, local machine... multiple machines.

Nicely filled out HTML page with all data related to OS

WMIC OS get /all /format:htable

Look at all the options available

ALIAS                    - Access to the aliases available on the local system
BASEBOARD                - Base board (also known as a motherboard or system board) management.
BIOS                     - Basic input/output services (BIOS) management.
BOOTCONFIG               - Boot configuration management.
CDROM                    - CD-ROM management.
COMPUTERSYSTEM           - Computer system management.
CPU                      - CPU management.
CSPRODUCT                - Computer system product information from SMBIOS.
DATAFILE                 - DataFile Management.
DCOMAPP                  - DCOM Application management.
DESKTOP                  - User's Desktop management.
DESKTOPMONITOR           - Desktop Monitor management.
DEVICEMEMORYADDRESS      - Device memory addresses management.
DISKDRIVE                - Physical disk drive management.
DISKQUOTA                - Disk space usage for NTFS volumes.
DMACHANNEL               - Direct memory access (DMA) channel management.
ENVIRONMENT              - System environment settings management.
FSDIR                    - Filesystem directory entry management.
GROUP                    - Group account management.
IDECONTROLLER            - IDE Controller management.
IRQ                      - Interrupt request line (IRQ) management.
JOB                      - Provides  access to the jobs scheduled using the schedule service.
LOADORDER                - Management of system services that define execution dependencies.
LOGICALDISK              - Local storage device management.
LOGON                    - LOGON Sessions.
MEMCACHE                 - Cache memory management.
MEMLOGICAL               - System memory management (configuration layout and availability of memory).
MEMPHYSICAL              - Computer system's physical memory management.
NETCLIENT                - Network Client management.
NETLOGIN                 - Network login information (of a particular user) management.
NETPROTOCOL              - Protocols (and their network characteristics) management.
NETUSE                   - Active network connection management.
NIC                      - Network Interface Controller (NIC) management.
NICCONFIG                - Network adapter management.
NTDOMAIN                 - NT Domain management.
NTEVENT                  - Entries in the NT Event Log.
NTEVENTLOG               - NT eventlog file management.
ONBOARDDEVICE            - Management of common adapter devices built into the motherboard (system board).
OS                       - Installed Operating System/s management.
PAGEFILE                 - Virtual memory file swapping management.
PAGEFILESET              - Page file settings management.
PARTITION                - Management of partitioned areas of a physical disk.
PORT                     - I/O port management.
PORTCONNECTOR            - Physical connection ports management.
PRINTER                  - Printer device management.
PRINTERCONFIG            - Printer device configuration management.
PRINTJOB                 - Print job management.
PROCESS                  - Process management.
PRODUCT                  - Installation package task management.
QFE                      - Quick Fix Engineering.
QUOTASETTING             - Setting information for disk quotas on a volume.
RECOVEROS                - Information that will be gathered from memory when the operating system fails.
REGISTRY                 - Computer system registry management.
SCSICONTROLLER           - SCSI Controller management.
SERVER                   - Server information management.
SERVICE                  - Service application management.
SHARE                    - Shared resource management.
SOFTWAREELEMENT          - Management of the  elements of a software product installed on a system.
SOFTWAREFEATURE          - Management of software product subsets of SoftwareElement.
SOUNDDEV                 - Sound Device management.
STARTUP                  - Management of commands that run automatically when users log onto the computer system.
SYSACCOUNT               - System account management.
SYSDRIVER                - Management of the system driver for a base service.
SYSTEMENCLOSURE          - Physical system enclosure management.
SYSTEMSLOT               - Management of physical connection points including ports,  slots and peripherals, and
TAPEDRIVE                - Tape drive management.
TEMPERATURE              - Data management of a temperature sensor (electronic thermometer).
TIMEZONE                 - Time zone data management.
UPS                      - Uninterruptible power supply (UPS) management.
USERACCOUNT              - User account management.
VOLTAGE                  - Voltage sensor (electronic voltmeter) data management.
VOLUMEQUOTASETTING       - Associates the disk quota setting with a specific disk volume.
WMISET                   - WMI service operational parameters management.

and many, many more.

1
  • @KAPes: "/format:htable" is awesome...
    – dance2die
    Jun 27, 2009 at 13:09
13
votes
color 02

This, my friends, is the only command you'll ever need. The rest is nonessential.

3
  • 2
    Oops, I accidentally entered color 23...
    – Andomar
    May 16, 2009 at 19:26
  • entering 'color' by itself takes you back to default
    – RobW
    Jun 16, 2010 at 20:16
  • Too bad it doesn't stick across CMD sessions...
    – Nate
    Jul 29, 2010 at 20:56
13
votes

Chaining commands, in particular net stop and start to restart any service:

net stop w3svc && net start w3svc

(It is a silly example as iisreset will do that, but anyway ;)

4
  • 5
    Just pointing out this is actually conditional execution, unlike a single '&'. ss64.com/nt/syntax-conditional.html May 22, 2009 at 19:25
  • True, it will only start if it the stop succeeded... or I guess that's the spirit anyway - not sure the net stop would actually return a non-success if it timed out.. testing May 22, 2009 at 22:28
  • Well as it does both even if one tries to stop a non-existing service, in this case it doesn't seem to matter - but the difference is of course great. They should add that "promote comment to answer" feature and I'd promote yours ^^ May 22, 2009 at 22:47
  • 3
    This will ensure a metabase configuration change is saved, however. IISRESET does not. Jun 10, 2009 at 16:03
12
votes
explorer .

Open explorer with the current folder selected.

explorer /e, .

Open explorer, with folder tree, with current folder selected.

2
  • This is also the way to make a shortcut that opens explorer for a specific directory, like "explorer /e,c:\myhomeisinrootthxu
    – Andomar
    May 16, 2009 at 19:37
  • Already integrated higher up the vote count... May 28, 2009 at 13:43
12
votes

To change the title of the CMD window you have open, simply use:

title [your new title]

I've got a lot of CMD windows and other programs open at work. This command, combined with Taskbar Shuffle (allows you to drag taskbar items into new orders) has saved me from insanity.

11
votes

Windows 7 Run Commands

I find it better to know where to find them until I have used them often enough to actually remember them.

1
  • Thanks Jake. I was looking for a list like those. My initial goal was to be able to browse through answers and find whatever a user might think will need by skimming through screenshots. But I guess I could do that myself ;)
    – dance2die
    May 4, 2009 at 14:25
10
votes

To restart IIS

iisreset
3
  • 3
    This can also be used to restart IIS on a remote server: iisreset remoteservername May 27, 2009 at 17:58
  • 3
    I don't use iisreset any longer. It may not save metabase config issue. I use net stop iisadmin /y && net start w3svc instead. Here's why: support.microsoft.com/default.aspx/kb/286196 Jun 10, 2009 at 16:02
  • @K. Brian Kelley, pretty sure the /noforce command will prevent the forcing and therefore keep you safe. IIS 7 is probably immune to it anyway since it no longer 'technically' uses the metabase.
    – Ashley
    Aug 3, 2011 at 21:07
10
votes

I didn't see taskkill on the list yet.

TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/F] [/T]

Parameter List: /S system Specifies the remote system to connect to.

/U    [domain\]user    Specifies the user context under which
                       the command should execute.

/P    [password]       Specifies the password for the given
                       user context. Prompts for input if omitted.

/F                     Specifies to forcefully terminate
                       process(es).

/FI   filter           Displays a set of tasks that match a
                       given criteria specified by the filter.

/PID  process id       Specifies the PID of the process that
                       has to be terminated.

/IM   image name       Specifies the image name of the process
                       that has to be terminated. Wildcard '*'
                       can be used to specify all image names.

/T                     Tree kill: terminates the specified process
                       and any child processes which were started by

it.

Works great in conjunction with tasklist

10
votes

You can hit F7 in The Windows Command Line for a history of commands that you can choose with your keyboard.

Also...I love this one - you can copy a file path by just dragging a file into the command line.

10
votes

On Windows XP at least (I haven't tried on Windows Vista and Windows 7):

appwiz.cpl @,2

It takes you straight to the Add/Remove Windows Components pane.

Another way to add or remove components in an automated fashion is to use

sysocmgr.exe

in unattended mode with a .inf file that lists the components you'd like to install. For example,

[NetOptionalComponents] 
SNMP = 1 

[SNMP] 
Contact_Name = IT Dept. 
Location = Office
Service = Physical, Applications, End-to-End 
Community_Name = Mormon 
Traps = server1, server2 
Send_Authentication = Yes 
Accept_CommunityName = Public:Read_Only 
Any_Host = No 
Limit_Host = server1, server2

(Credit due to thesystemadministrator.com for .inf file.)

It's a clunky tool (hey, it's MS), but it's invaluable for getting your components sorted out post-install.

1
  • 1
    "appwiz.cpl @,2" works but renamed to "Turn Windows Features On and Off"
    – dance2die
    May 4, 2009 at 23:39
9
votes
Device Manager
devmgmt.msc

Opens

enter image description here

1
  • 7
    If you set the environment variable devmgr_show_nonpresent_devices to 1 before launching device manager, then when you show hidden devices it will show all the completely inactive devices (e.g. have been removed) as well.
    – Richard
    May 4, 2009 at 9:35
8
votes

Registry Editor

regedit
1
2 3 4 5 6

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .