Welcome to the comprehensive guide to using the Command Prompt! Whether you're a complete beginner or looking to master advanced commands, this documentation will walk you through everything you need to know about the Command Prompt in Windows.
- Introduction to Command Prompt
- Basic Commands
- Intermediate Commands
- Advanced Commands
- Tips and Tricks
- Resources
The Command Prompt, also known as CMD, is a command-line interpreter application available in most Windows operating systems. It's a powerful tool that allows users to execute commands to perform various tasks, ranging from basic file management to complex scripting.
To open the Command Prompt:
- Press
Win + R
to open the Run dialog. - Type
cmd
and pressEnter
.
Alternatively, you can search for "cmd" or "Command Prompt" in the Start menu.
When you open the Command Prompt, you'll see something like this:
C:\Users\YourUsername>
C:
indicates the current drive.\Users\YourUsername
shows the current directory path.>
is the prompt symbol, indicating the Command Prompt is ready to accept commands.
Let's start with some fundamental commands to get you comfortable with the Command Prompt.
-
dir
: Lists the files and directories in the current directory.dir
-
cd
(Change Directory): Changes the current directory.- To navigate to a different directory:
cd path\to\directory
- To go up one level in the directory structure:
cd ..
- To navigate to a different directory:
-
cls
: Clears the Command Prompt screen.cls
-
mkdir
(Make Directory): Creates a new directory.mkdir NewFolder
-
rmdir
(Remove Directory): Deletes a directory.- To delete an empty directory:
rmdir FolderName
- To delete a directory and its contents:
rmdir /s /q FolderName
- To delete an empty directory:
-
copy
: Copies files from one location to another.copy SourceFile Destination
-
move
: Moves files from one location to another.move SourceFile Destination
-
del
: Deletes one or more files.del FileName
-
systeminfo
: Displays detailed configuration information about your computer.systeminfo
-
tasklist
: Lists all currently running tasks and their details.tasklist
-
taskkill
: Terminates a running process.taskkill /im ProcessName /f
-
ipconfig
: Displays the current network configuration.ipconfig
-
ping
: Tests connectivity to another networked device.ping www.example.com
-
tracert
: Traces the route taken to reach a networked device.tracert www.example.com
-
netstat
: Displays active network connections and statistics.netstat
Batch files are scripts that contain a series of commands to be executed sequentially by the Command Prompt.
-
Creating a Batch File:
- Open Notepad.
- Write your commands, one per line.
- Save the file with a
.bat
extension (e.g.,script.bat
).
-
Running a Batch File:
- In the Command Prompt, navigate to the directory containing the batch file.
- Type the name of the batch file and press
Enter
.script.bat
-
schtasks
: Schedules commands and programs to run periodically or at a specific time.- To create a new scheduled task:
schtasks /create /sc daily /tn "MyTask" /tr "C:\Path\To\Script.bat" /st 12:00
- To list all scheduled tasks:
schtasks /query
- To create a new scheduled task:
-
at
: Schedules commands and programs to run on a computer at a specified time and date.at 14:00 /every:M,T,W,Th,F "C:\Path\To\Script.bat"
- Autocomplete Paths: Press
Tab
while typing a path to autocomplete folder and file names. - Command History: Use the up and down arrow keys to cycle through previously entered commands.
- Redirection Operators: Use
>
to redirect output to a file and>>
to append to a file.dir > filelist.txt
- Microsoft Documentation: Command-Line Reference
- SS64: Comprehensive Command List
- Stack Overflow: Community Support