Sub topic 1
Command Prompt basics: elevation, help, and syntax
Prerequisites
This chapter assumes you can use the Windows desktop and File Explorer, and that you know the difference between an administrator account and a standard user account. You should also know what a file, folder, and drive are. No earlier command-line experience is needed.
Why the Command Prompt matters
Command Prompt (cmd.exe) is a text interface for running Windows commands. Many A+ Core 2 troubleshooting tasks, such as repairing disks, resetting network settings, and applying policy, are faster or only possible from here. Every later chapter in this tutorial builds on the three skills below: opening the right kind of prompt, reading help, and writing correct syntax.
Opening Command Prompt with elevation
A standard Command Prompt runs with your normal permissions. Commands that change the system, such as sfc, chkdsk /f, or diskpart, need an elevated prompt. Elevation means the program runs with administrator rights.
To open an elevated prompt:
- Select Start and type
cmd. - Right-click Command Prompt and choose Run as administrator.
- Approve the User Account Control (UAC) prompt. UAC is the Windows dialog that asks you to confirm a change that needs administrator rights.
The title bar of an elevated window begins with "Administrator:". If you run a command that needs elevation from a normal prompt, you usually see "Access is denied" or a message that the operation requires elevation.
Reading help with /?
Almost every command prints its own help when you add /?. The help lists the syntax, the switches, and often examples.
ping /?
help
help ipconfigcommand /?shows help for one command.helplists the built-in commands that Command Prompt supports.help commandshows the same text ascommand /?for built-in commands.
Reading syntax
Help text uses a standard notation. Learn to read it and you can use commands you have never seen.
| Notation | Meaning | Column |
|---|---|---|
| `/f` or `-f` | A switch, which changes how the command behaves | |
| `[ ]` | The item is optional | |
| `< >` or italics | A value you must replace, such as a file name | |
| `\ | ` | Choose one of the listed options |
A command is the program name, then its switches and arguments, separated by spaces. Most Windows commands use / for switches, but some tools such as ping and tracert also accept -. Case does not matter for commands or switches, but quote any path that contains spaces:
cd "C:\Program Files"A worked example
Suppose you need to restart a PC after 60 seconds. You do not remember the switches, so you ask for help first.
shutdown /?
shutdown /r /t 60
shutdown /aThe help shows that /r means restart and /t sets the delay in seconds. The last command, /a, aborts the pending shutdown. Reading help first, then running the command, is the habit to build.
Common errors
- Access is denied: the prompt is not elevated. Reopen it as administrator.
- "is not recognized as an internal or external command": the command name is misspelled, or the program is not in a folder listed in the PATH variable.
- "The syntax of the command is incorrect": a switch is wrong, or a path with spaces is missing quotes.
Exercise
You run sfc /scannow and see a message saying you must be an administrator. What do you do, and how can you confirm the fix worked?
Show answer
Close the window and reopen Command Prompt with Run as administrator, then approve the UAC prompt. The title bar will begin with "Administrator:", and sfc /scannow will now start scanning.
Exercise
Which command shows the switches available for ipconfig?
Show answer
ipconfig /?