Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share
11  
If you find this stuff interesting, take a look at commandlinefu: commandlinefu.com It's basically like digg for CLI –  username May 11 '09 at 6:47
1  
Try putting each command as a separate answer. Then we can vote and comment on each one. –  lamcro Jun 26 '09 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... –  David Alpert Jul 29 '09 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 '10 at 14:16
show 2 more comments

locked by Zypher Dec 11 '11 at 21:18

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

160 Answers

fsutil

From Microsoft Technet "Performs tasks that are related to file allocation table (FAT) and NTFS file systems, such as managing reparse points, managing sparse files, or dismounting a volume."

One of its most helpful options is to disable the creation of legacy 8.3 filenames. This is particularly helpful on servers that have very large numbers of files in a directory with long filenames.

To disable legacy 8.3 filenames on XP or Server 2003:

fsutil behavior set disable8dot3 1

On Windows 7 (and possibly Vista and Server 2008) you'd use:

fsutil 8dot3name set 1

For more information see: http://technet.microsoft.com/en-us/library/cc753059.aspx

share
show 2 more comments
netsh firewall set opmode disable 

turns off the Windows firewall.

taskkill.exe /f /fi "status eq Not Responding"

kills all not responding programs.

share
add comment

I just recently found out about forfiles

FORFILES [/P pathname] [/M searchmask] [/S] [/C command] [/D [+ | -] {MM/dd/yyyy | dd}]

Description: Selects a file (or set of files) and executes a command on that file. This is helpful for batch jobs.

I use this to delete old backups with this line, this basically deletes files that are older than 6 days:

Forfiles /p " C:\Backups\SQL " /d -6 /c "CMD /C del @FILE"
share
show 1 more comment

Network Connections (Windows Vista/Windows XP)

The command

ncpa.cpl

opens

alt text

share
show 1 more comment

dsquery * and dsmod

Pipe your dsquery results into dsmod and do mass changes to Active Directory.

Description:  Finds any objects in the directory according to criteria.

Syntax:     dsquery * [{<StartNode> | forestroot | domainroot}]
            [-scope {subtree | onelevel | base}] [-filter <LDAPFilter>]
            [-attr {<AttrList> | *}] [-attrsonly] [-l]
            [{-s <Server> | -d <Domain>}] [-u <UserName>]
            [-p {<Password> | *}] [-q] [-r] [-gc]
            [{-uc | -uco | -uci}]

Parameters:
Value                       Description
{<StartNode> | forestroot | domainroot}
                            The node where the search will start:
                            forest root, domain root, or a node
                            whose DN is <StartNode>.
                            Can be "forestroot", "domainroot" or an object
                            DN.
                            If "forestroot" is specified, the search is done
                            via the global catalog. Default: domainroot.
-scope {subtree | onelevel | base}
                            Specifies the scope of the search:
                            subtree rooted at start node (subtree);
                            immediate children of start node only (onelevel);
                            the base object represented by start node (base).
                            Note that subtree and domain scope
                            are essentially the same for any start node
                            unless the start node represents a domain root.
                            If forestroot is specified as <StartNode>,
                            subtree is the only valid scope.
                            Default: subtree.
-filter <LDAPFilter>        Specifies that the search use the explicit
                            LDAP search filter <LDAPFilter> specified in the
                            LDAP search filter format for searching.
                            Default:(objectCategory=*).The search filter
                            string must be enclosed in double quotes.
-attr {<AttrList> | *}      If <AttrList>, specifies a space-separated list
                            of LDAP display names to be returned for
                            each entry in the result set.
                            If *, specifies all attributes present on
                            the objects in the result set.
                            Default: distinguishedName.
-attrsonly                  Shows only the attribute types present on
                            the entries in the result set but not
                            their values.
                            Default: shows both attribute type and value.
-l                          Shows the entries in the search result set
                            in a list format. Default: table format.
{-s <Server> | -d <Domain>}
                            -s <Server> connects to the domain controller
                            (DC) with name <Server>.
                            -d <Domain> connects to a DC in domain <Domain>.
                            Default: a DC in the logon domain.
-u <UserName>               Connect as <UserName>. Default: the logged in
                            user. User name can be: user name,
                            domain\user name, or user principal name (UPN).
-p <Password>               Password for the user <UserName>. If * then you
                            are prompted for a password.
-q                          Quiet mode: suppress all output to standard
                            output.
-r                          Recurse or follow referrals during search.
                            Default: do not chase referrals during search.
-gc                         Search in the Active Directory global catalog.
-limit <NumObjects>         Specifies the number of objects matching the
                            given criteria to be returned, where <NumObjects>
                            is the number of objects to be returned.
                            If the value of <NumObjects> is 0, all matching
                            objects are returned. If this parameter is not
                            specified, by default the first 100 results are
                            displayed.
{-uc | -uco | -uci}         -uc Specifies that input from or output to pipe
                            is formatted in Unicode.
                            -uco Specifies that output to pipe or file is
                            formatted in Unicode.
                            -uci Specifies that input from pipe or file is
                            formatted in Unicode.

Remarks:
The dsquery commands help you find objects in the directory that match
a specified search criterion: the input to dsquery is a search criteria
and the output is a list of objects matching the search. To get the
properties of a specific object, use the dsget commands (dsget /?).

A user-entered value containing spaces or semicolons must be enclosed in
quotes (""). Multiple user-entered values must be separated using commas
(for example, a list of attribute types).


Examples:
To find all users in the current domain only whose SAM account name begins
with the string "jon" and display their SAM account name,
User Principal Name (UPN) and department in table format:

dsquery * domainroot
-filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=jon*))"
-attr sAMAccountName userPrincipalName department

To read the sAMAccountName, userPrincipalName and department attributes of
the object whose DN is ou=Test,dc=microsoft,dc=com:

Dsquery * ou=Test,dc=microsoft,dc=com -scope base
-attr sAMAccountName userPrincipalName department

To read all attributes of the object whose DN is ou=Test,dc=microsoft,dc=com:

Dsquery * ou=Test,dc=microsoft,dc=com -scope base -attr *

See also:
dsquery computer /? - help for finding computers in the directory.
dsquery contact /? - help for finding contacts in the directory.
dsquery subnet /? - help for finding subnets in the directory.
dsquery group /? - help for finding groups in the directory.
dsquery ou /? - help for finding organizational units in the directory.
dsquery site /? - help for finding sites in the directory.
dsquery server /? - help for finding servers in the directory.
dsquery user /? - help for finding users in the directory.
dsquery quota /? - help for finding quotas in the directory.
dsquery partition /? - help for finding partitions in the directory.
dsquery * /? - help for finding any object in the directory by using
a generic LDAP query.

Directory Service command-line tools help:
dsadd /? - help for adding objects.
dsget /? - help for displaying objects.
dsmod /? - help for modifying objects.
dsmove /? - help for moving objects.
dsquery /? - help for finding objects matching search criteria.
dsrm /? - help for deleting objects.
dsquery failed:The parameter is incorrect.
type dsquery /? for help.
share
add comment

Run something as a different user (good for troubleshooting w/o having people to log off)

runas /U:*domainname*\*username* "*someapplication*"

for example, if you want to open an explorer window with your credentials

runas /U:example.com\mylogin "explorer /separate"

for management console snapins (services in this example) you need to use mmc followed by the normal command to open that snap-in

runas /U:example.com\mylogin "mmc services.msc"

For situations where you need to run an application as a domain user from a non-domain-joined PC (eg SQL Server Management Studio)

runas /netonly /U:domain\username application.exe
share
add comment

ipconfig

USAGE:

ipconfig [/? | /all | /renew [adapter] | /release [adapter] |

          /flushdns | /displaydns | /registerdns |

          /showclassid adapter |

          /setclassid adapter [classid] ]

where

adapter         Connection name 

               (wildcard characters * and ? allowed, see

examples)

Options:

   /?           Display this help message

   /all         Display full configuration information.

   /release     Release the IP address for the specified adapter.

   /renew       Renew the IP address for the specified adapter.

   /flushdns    Purges the DNS Resolver cache.

   /registerdns Refreshes all DHCP leases and re-registers DNS names

   /displaydns  Display the contents of the DNS Resolver Cache.

   /showclassid Displays all the dhcp class IDs allowed for adapter.

   /setclassid  Modifies the dhcp class id.  

The default is to display only the IP address, subnet mask and

default gateway for each adapter bound to TCP/IP.

For Release and Renew, if no adapter name is specified, then the IP address

leases for all adapters bound to TCP/IP will be released or renewed.

For Setclassid, if no ClassId is specified, then the ClassId is removed.

Examples:

> ipconfig                   ... Show information.

> ipconfig /all              ... Show detailed information

> ipconfig /renew            ... renew all adapters

> ipconfig /renew EL*        ... renew any connection that has its 

                                 name starting with EL

> ipconfig /release *Con*    ... release all matching connections,

                                 eg. "Local Area Connection 1" or

                                     "Local Area Connection 2"
share
add comment
EventViewer
eventvwr.msc

Opens enter image description here

share
1  
You can just use "eventvwr" and save a few characters. –  boflynn May 4 '09 at 10:57
add comment

I find that often I need to create large files for testing.

fsutil file createnew C:\1_gb-ish_file.txt 1000000000

share
1  
I cant believe I didnt know this. Thanks for the tip! –  cop1152 Mar 24 '10 at 20:40
show 1 more comment
mstsc  # starts the Remote Desktop window.
mstsc -v 192.168.0.1  # to remotely connect to a given IP.
share
show 1 more comment

To get the current date / time for use in a batch file:

for /f "usebackq tokens=1,2,3,4 delims=/ " %%w in (`echo %DATE%`) do set YMD=%%z%%x%%y
for /f "usebackq tokens=1,2,3,4 delims=:." %%x in (`echo %TIME%`) do set HMS=%%x%%y%%z
set NOW=%YMD%_%HMS%
echo %NOW%
share
add comment

Windows Update Service

wuauclt.exe 

/demoui
/a /ResetAuthorization
/r /ReportNow
/detectnow

This single command has a lot of mythology surrounding it. It reports no errors, has no help dialog, and the only real output is run for /demoui. But it does work, I think.

Reference

share
add comment

The clip command on Windows Vista and Windows Server 2008 is very useful: it puts anything passed in on standard input on the clipboard.

Examples:

Copy current directory to clipboard:

dir | clip

List C files containing a particular string:

findstr /i /s /m /c:"someFunction" *.c | clip
share
add comment

Quite possibly the most powerful command yet:

cmd.exe

Favorite option:

/K Carries out the command specified by string but remains

share
add comment

subst.exe - associates a path with a drive letter, including local drives. Usage example (add then remove):

subst M: C:\Documents and Settings\user\My Music\
subst M: /D

(note: is not persistent and needs to be run on every logon)

share
show 1 more comment

I know this is a bit of an old question here, but I looked through the five pages of answers, and I did not see the following:

pushd, popd

Usage:

C:\Users\MyUser\src> pushd C:\Users\MyUser\Documents
C:\Users\MyUser\Documents> cd Backup
C:\Users\MyUser\Documents\Backup> copy ..\*.* .
C:\Users\MyUser\Documents\Backup> popd
C:\Users\MyUser\src> rem Continue working in src directory.

Useful when working in long directories. I want to get back where i was.

share
add comment

Lately I have had to use: net use \\servername /d

It kills permissions to specified resources.

Another use for net use is to re-mount a local drive as administrator, so that you don't need to log out (on WinXP, switch user was disabled on domains).

net use \\localShare /user:admin

share
add comment

rasdial

USAGE:
    rasdial entryname [username [password|*]] [/DOMAIN:domain]
            [/PHONE:phonenumber] [/CALLBACK:callbacknumber]
            [/PHONEBOOK:phonebookfile]
            [/PREFIXSUFFIX]

    rasdial [entryname] /DISCONNECT

    rasdial

    For Online Privacy Information please refer to
    'http://go.microsoft.com/fwlink/?LinkId=34493'

connects to a VPN or a dialup network from the command line.

share
add comment

Disk management from the command line:

diskpart

See A Description of the Diskpart Command-Line Utility for more information.

share
add comment

Forfiles:

forfiles

This is great for running a given command on any file that matches a list of criteria.

For example, the following will delete all files with a last modified date earlier than seven days ago:

forfiles -p . /D -7 /M *.* /S -c "cmd /C del @File /Q"
share
add comment

What about rundll32.exe?
It allows running functions from within any 32 bit DLL.
You can do almost everything with this command - and script your OS to your heart's content.
The syntax is:

RUNDLL32.EXE <dllname>,<entrypoint> <optional arguments>

E.G.:

RUNDLL32.EXE SHELL32.DLL,Control_RunDLL HotPlug.dll

Will bring up the "USB Disconnect" dialog (equivalent to right-clicking the "Safely Remove Hardware option in the system tray).

RUNDLL32 PRINTUI.DLL,PrintUIEntry /?

Will give you dozens of options to control your printer from the command line.
And there are millions more...

share
add comment

netsh

netsh can do many useful things, i.e: (no pun intended ;-)
Import proxy settings from Internet Options to command line tools:

netsh
netsh>winhttp
netsh winhttp>import proxy source=ie

Display current proxy settings:

netsh winhttp>show proxy  

net config server

Hide computer from Browser list:

net config server /hidden:yes
share
add comment

Local Security Settings

secpol.msc
share
show 1 more comment

The ever-so-appropriately named lusrmgr.msc - Local Users and Groups Administrator

share
show 1 more comment

If you suspect something's wrong with protected system files, you can use this tool.

sfc /scannow
share
add comment

Microsoft Windows Malicious Software Removal Tool

mrt
share
add comment

SC - Manage anything you want to do with services.

DESCRIPTION:
        SC is a command line program used for communicating with the
        NT Service Controller and services. USAGE:
        sc <server> [command] [service name] <option1> <option2>...
share
add comment

The set command with filtering to display contents of environment variables. Instead of typing

C:\Users\Erlend>echo %computername%
ASUS-G1S
you can type
C:\Users\Erlend>set comp
COMPUTERNAME=ASUS-G1S
to get the same effect. Using set alone shows you all environment variables.

share
show 1 more comment

One of my favourites is rsop.msc, 'Resultant Set of Policy'.

RSoP shows the combined effect of all group policies active on the current system/login. So on a client machine if you're unsure about which particular policy settings are/aren't applied, simply check it out in RSoP!

share
add comment

start:

start .                (opens explorer to the pwd)

start c:\              (opens explorer to the root of C:)

start document.doc     (open the document - just like double-clicking on it)

start wordpad file.txt (open wordpad for the file, creating if necessary)

start calc             (launch the calculator app)
share
add comment

protected by Iain Dec 11 '11 at 14:08

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.