You might be wondering, “Why should I even bother with the Command Line?” Well, good question! The Command Line is a powerful tool that lets you control your computer with just a few keystrokes. It’s convenient for tasks like managing files, troubleshooting issues, and even automating repetitive tasks.
This guide will walk you through the essential commands, from the basics of navigating your system to more advanced techniques.
What is the command line
The command line is a view of the operating system (OS) in text format. It is also called the console or terminal. It looks like a black window with white text. Using such a program you can control your computer, programs, or external devices. This can be useful if you want to do something that GUIs don’t allow you to do. To do this, the user must enter text commands.
How to Open Command Prompt in Windows as Administrator
The command line, when opened without special settings, works in normal user mode. This means that she does not have special rights that allow her to make changes to the system. There are many ways to open the command line using keys or, for example, through search.
1. Via “Start”
Start is the main menu in Windows. It allows you to access various programs, documents, and system settings. “Start” is located in the lower-left corner of the screen and resembles a rectangle divided into four parts – this is the operating system logo. The corresponding icon can also be seen on the keyboard.
How to open the command line in Windows via Start? First, click on the OS logo icon on the taskbar or keyboard. In Windows 8 and 10, in the list of programs, select “Windows Tools”, and in Windows 11 – “All applications” → “Windows Tools”. Then find “Command Prompt” and right-click. In “Advanced” use “Run as administrator”. Then the “Do you want to allow this app to make changes on your device?” window will appear. Click Yes.
2. “Search”
Open Start, click the magnifying glass icon on the taskbar or use the search box. Type “Command Prompt” on your keyboard. Then there are two options. Either use “Run as administrator” in the list that appears on the right, or right-click on the application icon under “Best Match” on the left.
3. “Task Manager”
Right-click on the taskbar and select “Task Manager”. Or use the key combination Ctrl+Shift+Esc. Click File → Run New Task. The command line is a program, and in Windows operating systems it is called cmd. Therefore, like any other file, it can be opened through the “Task Manager”. In the new window, type cmd and leave a checkmark next to “Create a task with administrator rights.” Click OK.
A faster option: select “File”, hold down the Ctrl key and click “Run new task”.
4. System32 folder
The command line can be used through the folder where the program is stored. Open Explorer → My Computer → Local Disk (C:) → Windows → System32. Find the cmd.exe application in the folder. Right-click on it → “Run as administrator.” Another way is to select the cmd.exe application and click on “Application Tools” at the top of the Explorer window. Then select “Run as administrator”.
5. Create a Shortcut
You can also create a shortcut for cmd.exe with admin rights. Right-click on the application, select “Send to” → “Desktop (create shortcut)”. On your desktop, right-click the cmd.exe shortcut again. Select Properties → Shortcut → Advanced. Check the box next to “Run as administrator”. Confirm and launch the application.
Desktop shortcuts are created for quick access to files, folders, programs and other objects. They allow you to save time on finding and launching the necessary objects, and also simplify the organization of your workspace on the screen. With the cmd shortcut on your desktop, you can easily access the command line.
6. “Explorer”
Explorer is a file manager that allows you to manage content on your computer. With it, you can create new folders, delete old ones, copy and move files between them. Explorer also allows you to view the properties of elements, change their characteristics and perform other operations.
Open File Explorer → My Computer. Type cmd.exe in the search. When your computer finds the file, right-click on it and select “Run as administrator.”
7. “Run”
Run is an application that allows you to quickly open a program, document, or website. To open a window with a command, simultaneously press the Windows key and the R button. Type cmd in the line, and then hold down the combination Ctrl+Shift+Enter. The command line will work with admin rights.
8. PowerShell
Modern versions of Windows use a command-line-like, pumped-up PowerShell program. It has a blue background and works on a different principle. At the same time, with its help, you can both open the cmd command line and perform other tasks. Press Win+X and select “Windows PowerShell (Admin).” Or use Win+R, type powershell and press Ctrl+Shift+Enter. Then type cmd and click Enter.
What is the command line for?
The command line can be compared to hotkeys. Only they are used not for one program, but for the entire operating system. This allows you to change hundreds of computer settings using the command line. And also take advantage of useful programs without leaving one window. Here are some of the most popular tasks.
1. Computer diagnostics
The command line allows you to fix errors in Windows. A special scan helps restore damaged or deleted system files. To run diagnostics, enter sfc /scannow at the command prompt. The window cannot be closed until the operation is completed.
2. System Restore
You can check your computer’s hard drive for errors. To do this, use the chkdsk C command. Instead of C, you can specify the letter of another drive. For additional actions, you need to specify parameters. For example, the command chkdsk C: /F /R means that the computer will check drive C. The letter F means that errors will be automatically corrected, and R means that the computer will check for bad sectors and try to recover information (R).
3. Working with disks
You can also manage your computer’s disks. To do this, use the diskpart command. With its help, you can change partitions, size, names, format drives, and carry out other operations. The full list of functions can be viewed using the diskpart help command.
4. Internet check
Command Prompt allows you to see your computer’s IP address. To do this, write ipconfig. If you need to determine the MAC address, enter getmac /v. You can also check the stability of the connection. For example, write the command ping hi-tech.mail.ru. The computer will send the data to our website and determine how quickly it will be returned. This way you will know if your Internet is working. The response time will indicate the quality of the connection. A good indicator is up to 40 ms.
5. Working with folders
You can replace Command Prompt with Explorer. With its help, you can access folders. The main command is called cd. It means changing the directory. For example, to open drive C, enter cd c:\. To access the folder inside, enter cd “folder name”. If there are spaces in the path name, add quotes.
6. Working with files
You can also open files or programs. To launch applications, you need to use the same cd command as with folders. However, please include the full file name and extension at the end of the address.
7. Checking active processes
You don’t need to use Task Manager to find out what programs are open on your computer. Type tasklist in the command line and you will see a similar list. The list will display all running processes and the memory they are consuming.
Basic Command Line Operations
Let’s start with some basic command line operations. Here’s a handy table that breaks down the essential commands, how to use them, and some examples to get you going.
Command | Usage | Example |
---|---|---|
cd | Change directory | cd C:\Users\YourName\Documents |
dir | List files and directories | dir |
tree | Display directory tree structure | tree C:\Users\YourName |
copy | Copy files from one location to another | copy file.txt D:\Backup\file.txt |
move | Move files from one location to another | move file.txt D:\Backup\file.txt |
del | Delete files | del file.txt |
mkdir | Create a new directory | mkdir NewFolder |
rmdir | Remove a directory | rmdir /S /Q OldFolder |
type | Display contents of a text file | type file.txt |
rename | Rename a file or directory | rename oldname.txt newname.txt |
cls | Clear the screen | cls |
exit | Close the Command Prompt window | exit |
These commands are your bread and butter for navigating and managing files and directories on your computer. Give them a try and see how they can make your tasks easier and faster!
Files and Folders Management
File and Folder management is also one of the most basic tasks that you perform on a computer. Whether you are organizing your files, backing up important data, or getting rid of files you no longer need knowing how to properly manage them can help save time and space. The Windows Command Line gives you a robust and capable set of tools to carry out many of the same jobs you can do in the GUI and some you can frequently with a finer level of control and precision, too.
At its most fundamental level, the operation of file and folder management is the basic manipulation of files and directories/files in a file system. But it doesn’t stop there. As you navigate through the file system you can also modify file attributes, set permissions, search for files, and even automate repetitive tasks with scripts. The command line lets you do this not only on your own machine but on machines connected to your network, which is a critical tool for everyday users as well as IT pros.
Automation is one of the biggest benefits of using the command line for file management. You can set things up like have a script to back up documents with the plan being executed nightly, or a batch file that can clean out temporary files for different directories in just a command.
Command | Usage | Example |
---|---|---|
cd | Change the current directory | cd C:\Users\YourName\Documents |
dir | List files and directories in the current directory | dir |
tree | Display directory tree structure | tree C:\Users\YourName |
copy | Copy one or more files to another location | copy file.txt D:\Backup\file.txt |
xcopy | Copy files and directories, including subdirectories | xcopy C:\Folder D:\Backup\Folder /E |
robocopy | Robust file copy for mirroring directories | robocopy C:\Folder D:\Backup\Folder /MIR |
move | Move files from one location to another | move file.txt D:\Backup\file.txt |
del | Delete one or more files | del file.txt |
erase | Another command to delete files | erase file.txt |
mkdir | Create a new directory | mkdir NewFolder |
md | Alias for mkdir | md NewFolder |
rmdir | Remove a directory | rmdir /S /Q OldFolder |
rd | Alias for rmdir | rd /S /Q OldFolder |
type | Display contents of a text file | type file.txt |
more | View file content one screen at a time | more file.txt |
rename | Rename a file or directory | rename oldname.txt newname.txt |
ren | Alias for rename | ren oldname.txt newname.txt |
attrib | Display or change file attributes | attrib +r file.txt |
cacls | Display or modify access control lists (ACLs) | cacls file.txt /G YourName:F |
icacls | Display, modify, backup, or restore ACLs for files | icacls file.txt /grant YourName:F |
compact | Display or alter the compression of files | compact /c file.txt |
diskpart | Manage disks, partitions, or volumes | diskpart (and then use DISKPART commands) |
takeown | Take ownership of a file or directory | takeown /F file.txt |
icacls | Change ownership of a file or directory | icacls file.txt /setowner YourName |
find | Search for a text string in a file or files | find "search text" file.txt |
findstr | Search for strings in files | findstr "search text" *.txt |
fc | Compare two files and display differences | fc file1.txt file2.txt |
mklink | Create symbolic links and hard links | mklink link.txt target.txt |
fsutil | File system utility to manage volumes | fsutil file createnew file.txt 1024 |
pushd | Save the current directory and change to a new one | pushd D:\Backup |
popd | Restore the previous directory saved by pushd | popd |
subst | Associate a path with a drive letter | subst X: C:\Path\To\Folder |
chkdsk | Check a disk and display a status report | chkdsk C: /F |
cipher | Encrypt or decrypt files and directories | cipher /E /S:C:\Users\YourName\Documents |
recover | Recover readable information from a bad or defective disk | recover C:\Folder\file.txt |
fsutil | Perform tasks related to file systems or disks | fsutil fsinfo drives |
attrib | Change file attributes | attrib +r -s -h file.txt |
vol | Display the disk volume label and serial number | vol C: |
label | Create, change, or delete the volume label | label C: MyDrive |
These commands should give you a solid foundation for managing files and folders on your Windows system.
Disks Management
Disk management is an important factor to keep your computer healthy and fast. Whether you are setting up a new system or upgrading storage or trying to fix a problem, a good understanding of disk management commands can be very beneficial. Windows Command Line has powerful set of tools that help in doing disk related things very quickly and almost 100% achieve the level of preciseness.
Disk management is a domain that includes specially partitioning, formatting, and checking your physical drive health. Command-line tools allow you to have more control and flexibility over these processes compared to using graphical interfaces only.
Partitioning is also one of the main functions in disk management. Partitions carve up the physical disk into distinct sections that can be managed individually. This enables you to better organize the data and can increase the system efficiency. You could also specify different partitions for the OS, Apps, and Home folders, for example The command line supplies commands to create, destroy, and manipulate these partitions with great accuracy.
Command | Usage | Example |
---|---|---|
diskpart | Enter DiskPart command interpreter for managing disks and partitions | diskpart |
list disk | List all disks connected to the system (within DiskPart) | list disk (after starting DiskPart) |
select disk | Select a specific disk to work with (within DiskPart) | select disk 0 |
list partition | List partitions on the selected disk (within DiskPart) | list partition |
select partition | Select a specific partition to work with (within DiskPart) | select partition 1 |
create partition | Create a new partition (within DiskPart) | create partition primary size=10240 |
delete partition | Delete a selected partition (within DiskPart) | delete partition |
extend | Extend the volume of the selected partition (within DiskPart) | extend size=2048 |
shrink | Shrink the volume of the selected partition (within DiskPart) | shrink desired=1024 |
assign | Assign a drive letter or mount point to the selected partition (within DiskPart) | assign letter=E |
remove | Remove a drive letter or mount point (within DiskPart) | remove letter=E |
format | Format a disk or partition | format E: /FS:NTFS /Q |
chkdsk | Check a disk and display a status report | chkdsk C: /F |
defrag | Defragment a disk | defrag C: |
diskperf | Manage disk performance counters | diskperf -y |
convert | Convert a volume from one file system to another | convert E: /FS:NTFS |
fsutil | Perform tasks related to file systems or disks | fsutil fsinfo drives |
mountvol | Create, delete, or list a volume mount point | mountvol E: /D |
vssadmin | Manage Volume Shadow Copy Service | vssadmin list shadows |
diskraid | GUI-based disk management tool | diskraid |
wmic | Use Windows Management Instrumentation Command to manage disks | wmic diskdrive get status |
sfc | System File Checker to scan and repair protected system files | sfc /scannow |
dism | Deployment Image Servicing and Management tool to service Windows images | dism /Online /Cleanup-Image /RestoreHealth |
bcdedit | Manage Boot Configuration Data | bcdedit /enum |
diskshadow | Create and manage volume shadow copies | diskshadow |
diskmgmt.msc | Open Disk Management console | diskmgmt.msc (Run command) |
partassist | Partition Assistant command line utility | partassist /cmd=cre /pri /size=10240 /disk=1 |
get-disk | PowerShell command to get disk information | Get-Disk |
new-partition | PowerShell command to create a new partition | New-Partition -DiskNumber 1 -Size 10GB -DriveLetter E |
format-volume | PowerShell command to format a volume | Format-Volume -DriveLetter E -FileSystem NTFS -NewFileSystemLabel "Data" |
resize-partition | PowerShell command to resize a partition | Resize-Partition -DriveLetter E -Size 20GB |
repair-volume | PowerShell command to repair a volume | Repair-Volume -DriveLetter C -OfflineScanAndFix |
System Information
Knowing how to find and control your computer system information is important for making your performance stay primo, fixing your problems, or making sure your system can run specific software and tasks. The Windows Command Line includes a suite of more than 280 individual commands that you can use to display detailed information about your system’s hardware and software configuration.
System information includes such data points as the CPU, memory, storage, and network interfaces, and various aspects of the system like the operating system, which software is installed, and what processes are running. Easily accessible information that can be used to make informed decisions on upgrades, diagnose performance bottlenecks, and troubleshoot other issues with the system.
Command | Usage | Example |
---|---|---|
systeminfo | Display detailed system information | systeminfo |
hostname | Show the computer’s hostname | hostname |
ver | Display the Windows version | ver |
wmic os get | Retrieve various OS information | wmic os get Caption, Version, BuildNumber |
wmic bios | Get BIOS information | wmic bios get Manufacturer, Name, Version |
wmic cpu | Display CPU information | wmic cpu get Name, NumberOfCores, NumberOfLogicalProcessors |
wmic memorychip | Retrieve memory information | wmic memorychip get Capacity, Manufacturer, Speed |
wmic diskdrive | Get information about disk drives | wmic diskdrive get Model, Size, Status |
msinfo32 | Open the System Information tool | msinfo32 (Run command) |
dxdiag | Open the DirectX Diagnostic Tool | dxdiag (Run command) |
tasklist | List all running processes | tasklist |
tasklist /svc | List services hosted in each process | tasklist /svc |
tasklist /m | List all DLL modules loaded by each process | tasklist /m |
taskkill | Terminate a running process | taskkill /PID 1234 |
netstat | Display network connections, routing tables, and interface statistics | netstat -an |
ipconfig | Display IP configuration | ipconfig |
ipconfig /all | Show detailed IP configuration | ipconfig /all |
ipconfig /release | Release all IP addresses | ipconfig /release |
ipconfig /renew | Renew all IP addresses | ipconfig /renew |
ping | Test connectivity to a network host | ping google.com |
tracert | Trace the route packets take to a network host | tracert google.com |
getmac | Display MAC addresses for network adapters | getmac |
netsh | Configure and display network settings | netsh interface ip show config |
whoami | Display the currently logged-in user | whoami |
echo %username% | Display the current username | echo %username% |
powercfg /batteryreport | Generate a battery report (laptops) | powercfg /batteryreport |
powercfg /energy | Generate a system energy report | powercfg /energy |
gpresult /R | Display Resultant Set of Policy (RSOP) for user and computer | gpresult /R |
net user | Display user account information | net user |
systeminfo /S <computer> | Retrieve system information from a remote computer | systeminfo /S remotePC |
query user | Display information about user sessions on a terminal server | query user |
sc query | Display information about running services | sc query |
sc qc | Display configuration information for a service | sc qc servicename |
schtasks | Display scheduled tasks | schtasks /query /fo LIST /v |
reg query | Display registry information | reg query HKLM\Software\Microsoft\Windows\CurrentVersion |
fsutil fsinfo | Display file system information | fsutil fsinfo drives |
Network Commands
Setting up and maintaining network configurations helps maintain solid connectivity and high performance in your computer systems. From setting up a small home network to troubleshooting connectivity issues over a VPN Windows Command Line commands offer a robust set of tools help you to manage and diagnose your network related tasks.
There are many network components and settings which are done when you install an operating system (OS) to your machine, in this guide I will only talk a little about IP address configuration. Being able to control these components via the command line can not only strengthen the stability of your network, it also offer more power and freedom compared to GUIs.
Command | Usage | Example |
---|---|---|
ipconfig | Display IP configuration | ipconfig |
ipconfig /all | Show detailed IP configuration | ipconfig /all |
ipconfig /release | Release all IP addresses | ipconfig /release |
ipconfig /renew | Renew all IP addresses | ipconfig /renew |
ipconfig /flushdns | Flush DNS resolver cache | ipconfig /flushdns |
ipconfig /displaydns | Display DNS resolver cache | ipconfig /displaydns |
ping | Test connectivity to a network host | ping google.com |
ping -t | Ping a host continuously | ping -t google.com |
ping -n | Ping a host a specific number of times | ping -n 10 google.com |
tracert | Trace the route packets take to a network host | tracert google.com |
traceroute | Alias for tracert on some systems | traceroute google.com |
pathping | Combine ping and tracert to locate network issues | pathping google.com |
netstat | Display network connections, routing tables, and interface statistics | netstat -an |
netstat -e | Display Ethernet statistics | netstat -e |
netstat -r | Display routing table | netstat -r |
netstat -s | Display per-protocol statistics | netstat -s |
arp | Display and modify the ARP cache | arp -a |
nslookup | Query the DNS to obtain domain name or IP address mapping | nslookup google.com |
route | Display and modify the IP routing table | route print |
route add | Add a static route to the routing table | route add 192.168.1.0 mask 255.255.255.0 192.168.1.1 |
route delete | Delete a route from the routing table | route delete 192.168.1.0 |
getmac | Display MAC addresses for network adapters | getmac |
netsh | Configure and display network settings | netsh interface ip show config |
netsh wlan | Manage wireless networks | netsh wlan show profiles |
netsh advfirewall | Manage Windows Firewall settings | netsh advfirewall set allprofiles state off |
nbtstat | Display NetBIOS over TCP/IP statistics and resolve NetBIOS names | nbtstat -a computername |
telnet | Connect to a remote host using Telnet | telnet towel.blinkenlights.nl |
ftp | Transfer files to/from a remote host using FTP | ftp ftp.example.com |
sftp | Securely transfer files to/from a remote host using SFTP | sftp user@example.com |
ssh | Securely connect to a remote host using SSH | ssh user@example.com |
net | Command for network operations | net view |
net view | View network resources | net view \\servername |
net use | Connect to or disconnect from a shared resource | net use Z: \\servername\sharename |
net user | Manage user accounts | net user username /add |
net start | Start a network service | net start servicename |
net stop | Stop a network service | net stop servicename |
net share | Create and manage shared resources | net share sharename=C:\Path\To\Folder |
netsh interface | Configure network interfaces | netsh interface ipv4 set address "Local Area Connection" static 192.168.1.100 255.255.255.0 192.168.1.1 |
netsh lan | Manage local area network settings | netsh lan show profiles |
netsh int ip reset | Reset TCP/IP stack | netsh int ip reset resetlog.txt |
Applications and Processes
Being able to manage applications and processes is a key skill that will help prevent your operating system from bogging down, and that will keep you in control of what your computer is doing at all times. For troubleshooting non-responsive applications, performance optimization or process control and resource management, the Windows Command Line provides various tools to manage such efficiently and that too, in a proper way.
An application is just a piece of software that you use on a computer – like a web browser, your favorite word processing app, or a game. Processes, alternatively, are running program instances. Every running app is represented by one or more processes, not just the primary executable, but any supporting processes or background services.
Command | Usage | Example |
---|---|---|
start | Start a program or open a document | start notepad.exe |
tasklist | Display a list of currently running processes | tasklist |
taskkill | Terminate a running process | taskkill /PID 1234 |
taskkill /IM | Terminate a process by its name | taskkill /IM notepad.exe |
wmic process list | Display detailed information about processes | wmic process list brief |
wmic process where | Filter and display process information | wmic process where "name='notepad.exe'" get ProcessId |
taskmgr | Open Task Manager | taskmgr |
sc query | Display information about running services | sc query |
sc start | Start a service | sc start servicename |
sc stop | Stop a service | sc stop servicename |
sc config | Configure a service | sc config servicename start= auto |
net start | Start a network service | net start servicename |
net stop | Stop a network service | net stop servicename |
schtasks | Schedule commands and programs to run at a specific time | schtasks /create /tn "MyTask" /tr "C:\Path\To\Program.exe" /sc daily /st 09:00 |
at | Schedule commands and programs to run at a specific time (deprecated) | at 14:00 /interactive "C:\Path\To\Program.exe" |
powershell | Run PowerShell commands or scripts | powershell Start-Process notepad |
runas | Run a program as another user | runas /user:administrator cmd |
shutdown | Shutdown or restart the computer | shutdown /r /t 0 |
logoff | Log off the current user | logoff |
msg | Send a message to another user | msg username "Your message here" |
sfc | System File Checker to scan and repair protected system files | sfc /scannow |
dism | Deployment Image Servicing and Management tool to service Windows images | dism /Online /Cleanup-Image /RestoreHealth |
get-process | PowerShell command to get a list of processes | Get-Process |
stop-process | PowerShell command to stop a process | Stop-Process -Name notepad |
start-process | PowerShell command to start a process | Start-Process -FilePath "C:\Path\To\Program.exe" |
get-service | PowerShell command to get the status of services | Get-Service |
start-service | PowerShell command to start a service | Start-Service -Name servicename |
stop-service | PowerShell command to stop a service | Stop-Service -Name servicename |
restart-service | PowerShell command to restart a service | Restart-Service -Name servicename |
set-service | PowerShell command to change the startup type of a service | Set-Service -Name servicename -StartupType Automatic |
wmic service | Display detailed information about services | wmic service get name, startmode, state |
wmic service where | Filter and display service information | wmic service where "name='servicename'" get startmode, state |
Command Line Setup
Prepare Command Line EnvironmentThis is something basic and every one should do if you ever need to take help of Windows Command Line. Configuring your command line to fit in with your workflow will make the experience of using CLI much more pleasant — no matter whether you are a developer, system administrator or just a casual user.
The command line (Command Prompt is another name for this) is a classic text-based user interface where you can execute commands by giving text instructions. The command line provides more precision and power than graphical interfaces which allow you to perform complex tasks with a few keystrokes. Tailoring and setting up your command line environment the way you want it can help you work faster and automate everyday tasks, or just create the best possible environment for the way you work.
Command | Usage | Example |
---|---|---|
prompt | Customize the command prompt appearance | prompt $P$G |
color | Change the color of the command prompt text and background | color 0A |
title | Set the title of the Command Prompt window | title My Custom Command Prompt |
cls | Clear the command prompt screen | cls |
doskey | Create command aliases and recall command history | doskey ls=dir /B |
set | Set or display environment variables | set PATH=C:\MyPrograms;%PATH% |
echo | Display messages or turn command echoing on or off | echo Hello, World! |
chcp | Display or set the active code page number | chcp 65001 |
mode | Configure system devices, like setting the window size | mode con: cols=120 lines=30 |
assoc | Display or modify file extension associations | assoc .txt=txtfile |
ftype | Display or modify file types used in file extension associations | ftype txtfile=C:\Windows\System32\NOTEPAD.EXE %1 |
path | Display or set the search path for executable files | path C:\MyPrograms;%path% |
reg | Manage the registry from the command line | reg add HKCU\Software\MyApp /v MyValue /t REG_SZ /d MyData |
setx | Set environment variables permanently | setx PATH "C:\MyPrograms;%PATH%" |
powershell | Launch PowerShell from the Command Prompt | powershell |
cmdkey | Manage stored usernames and passwords | cmdkey /add:server /user:username /pass:password |
comp | Compare the contents of two files or sets of files | comp file1.txt file2.txt |
fc | Compare two files and display the differences | fc file1.txt file2.txt |
tree | Display the directory structure of a drive or path | tree C:\ /F |
runas | Run a program as another user | runas /user:administrator cmd |
schtasks | Schedule commands and programs to run at a specific time | schtasks /create /tn "MyTask" /tr "C:\Path\To\Program.exe" /sc daily /st 09:00 |
shutdown | Shutdown or restart the computer | shutdown /r /t 0 |
taskkill | Terminate a running process | taskkill /PID 1234 |
tasklist | Display a list of currently running processes | tasklist |
wmic | Windows Management Instrumentation Command to manage various system settings | wmic path win32_computersystem get name |
attrib | Display or change file attributes | attrib +r -s -h file.txt |
cacls | Display or modify access control lists (ACLs) of files | cacls file.txt /G username:F |
icacls | Display, modify, backup, or restore ACLs for files and directories | icacls file.txt /grant username:F |
gpupdate | Update Group Policy settings | gpupdate /force |
gpresult | Display Resultant Set of Policy (RSOP) for a user or computer | gpresult /R |
systeminfo | Display detailed configuration information about the computer and its operating system | systeminfo |
ver | Display the Windows version | ver |
hostname | Display the name of the current computer | hostname |
whoami | Display the current username | whoami |
schtasks | Schedule tasks to run automatically | schtasks /create /tn "Backup" /tr "C:\BackupScript.bat" /sc weekly /d Sun /st 02:00 |
Tips for Setting Up Your Command Line Environment
- Customizing the Prompt: Use the
prompt
command to make your command prompt more informative or fun. For example,prompt $P$G
sets the prompt to display the current directory followed by a greater-than sign (>
). - Changing Colors: The
color
command changes the text and background colors of the command prompt. For instance,color 0A
sets the background to black and the text to light green. - Setting Environment Variables: Use the
set
command to define environment variables for the current session andsetx
to set them permanently. This is useful for adding directories to yourPATH
or setting other environment-specific values. - Creating Aliases: The
doskey
command allows you to create shortcuts for longer commands. For example,doskey ls=dir /B
makes thels
command function likedir /B
. - Window Size and Buffer: Adjust the window size and buffer with the
mode
command. For instance,mode con: cols=120 lines=30
sets the command prompt window to 120 columns wide and 30 lines tall. - Persistent Changes: Use the
setx
command to make permanent changes to environment variables, which ensures your custom setup remains even after rebooting. - Launching PowerShell: If you need more advanced scripting capabilities, you can switch to PowerShell by simply typing
powershell
in the command prompt. - Task Scheduling: Automate tasks using the
schtasks
command to schedule scripts or programs to run at specific times.
Conclusion
We hope this cheat sheet for the Windows Command Line helps you a little to complete your tasks as quickly and efficiently as possible. It is easy to confuse command prompt commands in Windows with other terminal scripting languages, but with this guide, this is all you need to regulate yourselves.
The Windows Command Line is a wonderful tool for any Windows person. It provides a degree of power and efficiency that could completely change the way you use your computer. Whether you are new to it or an expert in command prompt coding, this cheat sheet should help you perform the tasks that you require.