20 Commands you must know in Windows
In this article you will learn about 20 Commands you must know in Windows. The command prompt is still a useful tool in Windows. Here are the most important CMD commands that every Windows user should know.
The command prompt is gradually disappearing from the Windows interface, and for good reason: CMD commands are an antiquated and mostly unnecessary tool from a time when text-based input was the norm. Many commands in Windows however, remain very useful, and Windows 8 and 10 even added new ones. We’ve compiled a list of the most important commands that every Windows user should be aware of.
If you feel that you unsure on how to get into and access the Windows command prompt, and have forgotten some of the basic Windows commands, or want to see a list of switches for each command (aka prompt codes)?
Commands you must know in Windows Command Prompt
You’re missing out if you haven’t explored the command line in Windows. If you know what to type, you can access a plethora of useful tools.
Command 1: Assoc
In Windows, most files are associated with a specific program that is set to open the file by default. Remembering these associations can be difficult at times.
You can refresh your memory by running the command assoc, which displays a complete list of filename extensions and program associations.
The command can also be extended to change file associations.
Assoc.txt=, for example, changes the file association for text files to whatever program you enter after the equal sign.
The assoc command will display both the extension and program names, which will assist you in properly using this command.
In Windows 10, you can see a more user-friendly interface, as well as the ability to change file type associations on the fly.
Navigate to Settings (Windows + I) > Apps > Default Apps. Select the default app based on the file type.
Command 2: Cipher
Deleted files on a mechanical hard drive are not truly deleted. Instead, it indicates that the files are no longer accessible and that the space they occupied is now free.
The files can be recovered until the system overwrites them with new data, which can take a while. The cypher command, on the other hand, deletes a directory by writing random data to it.
To wipe your C drive, for example, use the cypher /w:d command, which will remove all free space from the drive. Because the command does not overwrite undeleted data, running it will not delete the files you require.
Some of the Other useful cypher commands are available, but they are somehow generally redundant with BitLocker-enabled versions of Windows.
Command 3: Driverquery
Drivers are still among the most important pieces of software that can be installed on a computer.
old drivers, missing, or Improperly configured in Windows can cause all kinds of problems, so it’s useful to have a list of what’s on your computer.
That is precisely what the driverquery command accomplishes. You can use the command driverquery -v to get some more information, such as the directory where the driver is installed.
Command 4: FileCompare
This command can be used to detect text differences between two files. It’s especially useful for writers and programmers looking for minor differences between two versions of a file.
Simply enter fc followed by the directory path and file name of the two files to be compared. The command can also be extended in a variety of ways.
Typing /b compares only binary output, /c ignores text case in the comparison, and /l compares only ASCII text. You could, for example, use the following:
C:UsersFatah GabrialDesktop>fc “C:UsersFatah GabrialDesktopfile1.txt” “C:UsersFatah GabrialDesktopfile2.txt”
The command above compares the ASCII text in two text documents.
Command 5: IpConfig
This command sends the IP address that your computer is currently using to the server. However, if you’re behind a router (as most computers are nowadays), you’ll get the router’s local network address instead.
Nonetheless, ipconfig is useful due to its extensions. The commands ipconfig /release followed by ipconfig /renew can force your Windows PC to request a new IP address, which is useful if your computer claims none are available.
To refresh your DNS address, use ipconfig /flushdns.
These commands are useful if the Windows network troubleshooter freezes, which does happen from time to time.
Command 6: NetStat
Entering the command netstat -an will return a list of currently open ports and their associated IP addresses. This command will also inform you of the port’s status, whether it is listening, established, or closed.
This is a great command to use when you’re trying to troubleshoot devices connected to your PC or when you suspect your system has been infected by a Trojan and you’re looking for a malicious connection.
Command 7: Ping
Sometimes you need to know if packets are being delivered to a specific networked device. This is where ping comes in.
When you type ping followed by an IP address or web domain, a series of test packets are sent to the specified address.
If they arrive and are returned, you know the device is capable of communicating with your computer; if they fail, you know something is interfering with communication between the device and your computer.
This can assist you in determining whether the source of the problem is an incorrect configuration or a failure of network hardware.
Command 8: Pathping
This is a more advanced version of ping that comes in handy if there are multiple routers between your PC and the device you’re testing.
Pathping is like ping, and it can be used by typing pathping followed by the IP address, but unlike ping, pathping also relays information about the route the test packets take.
Command 9: Trancert
Pathping is similar to the tracert command.Once more, enter tracert followed by the IP address or domain to be traced.
You will be informed about each step of the path between your PC and the target. Tracert, unlike pathping, also tracks how long (in milliseconds) each hop between servers or devices takes.
Command 10: Powercfg
Powercfg is a very powerful command for managing and tracking how much energy your computer consumes. To manage hibernation, use the commands powercfg hibernate on and powercfg hibernate off, and you can also use the command powercfg /a to view the power-saving states currently available on your PC.
Powercfg /devicequery s1 supported is another useful command that displays a list of devices on your computer that support connected standby. When enabled, you can use these devices to wake up your computer, even remotely.
Select the device in Device Manager, open its properties, navigate to the Power Management tab, and then check the Allow this device to wake the computer box.
Powercfg /lastwake will display the device that last woke your PC from a sleep state. You can use this command to troubleshoot your computer if it appears to wake up at random.
You can generate a detailed power consumption report for your PC by using the powercfg /energy command. After the command completes, the report is saved to the specified directory.
This report will notify you of any system flaws that may increase power consumption, such as devices that block certain sleep modes or are not properly configured to respond to your power management settings.
Windows 8 includes the powercfg /batteryreport command, which provides a detailed analysis of battery usage, if applicable.
The report, which is normally saved to your Windows user directory, includes information such as the time and length of charge and discharge cycles, lifetime average battery life, and estimated battery capacity.
Command 11: Poweroff
Windows 8 introduced the shutdown command, which, as the name suggests, shuts down your computer.
The shutdown /r /o command, which restarts your PC and launches the Advanced Start Options menu, where you can access Safe Mode and Windows recovery utilities, is, of course, redundant with the already easily accessible shutdown button, but it isn’t.
This is useful if you need to restart your computer to troubleshoot.
Command 12: Systeminfo
This command will provide you with a detailed overview of your computer’s configuration. The list includes your operating system as well as your hardware.
You can, for example, look up the original Windows installation date, the last boot time, your BIOS version, total and available memory, installed hotfixes, network card configurations, and other information.
To remotely obtain information for a computer on your local network, type systeminfo /s followed by the hostname of that computer.
This may necessitate the addition of additional syntax elements for the domain, user name, and password, such as:
systeminfo /s /u /p
Command 13: System File Checker
System File Checker is an automatic scan and repair utility for Windows system files. You must launch the command prompt with administrative privileges and type sfc /scannow.
If SFC discovers any corrupted or missing files, it will automatically replace them with cached copies kept by Windows solely for this purpose.
On older notebooks, the command may take up to a half-hour to complete.
Command 14: Tasklist
You can use the tasklist command to get a list of all the tasks that are currently running on your computer. Though somewhat redundant with Task Manager, the command may occasionally discover tasks that are hidden from view in that utility.
There is also a diverse set of modifiers. Tasklist -svc displays services associated with each task; tasklist -v displays more information about each task; and tasklist -m locates DLL files associated with active tasks.
These commands can help with advanced troubleshooting. You can “get the name of the executable associated with the particular process ID you’re interested in,” according to reader Eric.
tasklist | find is the command for that operation.
Command 15: Taskkill
Tasks that appear in the tasklist command will be assigned an executable and a process ID (a four- or five-digit number).
You can force a programme to stop by typing taskkill -im followed by the name of the executable or taskkill -pid followed by the process ID.
Again, this is somewhat redundant with Task Manager, but it can be used to terminate otherwise inactive or hidden programmes.
Command 16: chkdsk
When symptoms indicate that a local drive has bad sectors, lost clusters, or other logical or physical errors, Windows automatically marks your drive for a diagnostic chkdsk scan.
If you suspect your hard drive is failing, you can run a scan manually. The most basic command is chkdsk c:, which will scan the C: drive without restarting the computer.
If you include parameters such as /f, /r, /x, or /b, as in chkdsk /f /r /x /b c:, chkdsk will also fix errors, recover data, dismount the drive, or clear the list of bad sectors, as appropriate.
These actions necessitate a reboot because they can only be performed while Windows is turned off.
Command 17: Schtasks
Schtasks is a command-line interface to the Task Scheduler, one of many underutilised Windows administrative tools.
While you can manage your scheduled tasks using the GUI, the command prompt allows you to copy&paste complex commands to set up multiple similar tasks without having to click through various options.
Finally, once you’ve committed key parameters to memory, it’s much easier to use. You could, for example, set your computer to reboot at 11 p.m. every Friday:
schtasks /create /sc weekly /d FRI /tn “auto reboot computer weekly” /st 23:00 /tr “shutdown -r -f -t 10”
You could schedule tasks to launch specific programmes on startup to supplement your weekly reboot:
schtasks /create /sc onstart /tn “launch Chrome on startup” /tr “C:Program Files (x86)GoogleChromeApplicationChrome.exe”
Simply copy, paste, and modify the above command to duplicate it for different programmes.
Command 18: Format
When it comes to formatting a drive, you have two options: use the Windows File Explorer GUI or use the command prompt. To use this command, you must have Administrator privileges. Make sure you specify the volume you want to format, followed by the parameters you want.
The command below will quickly format the D drive with the exFAT file system and rename the volume to “label” with an allocation unit size of 2048 bytes (without the quotes).
format D: /Q /FS:exFAT /A:2048 /V:label
This command can also be used to unmount a volume (/X) or, if it’s formatted with NTFS, to make file compression the default setting (/R).
If you get stuck, type format /? to get help.
Command 19: Prompt
Do you want to add instructions or specific information to your command prompt? You can use the prompt command to do so!
Consider this:
prompt Your wish is my command:
You can include the current time, date, drive and path, Windows version number, and many other details.
prompt $t on $d at $p using $v:
To reset your command prompt to its default settings, type “prompt” or simply restart the command prompt. Regrettably, these options are not permanent.
Command 20: Cls
Have you clogged up your command prompt window by attempting all of the commands listed above?
To clean it all up again, you’ll need to know one more command.
Cls
That’s all there is to it. I’m sure Marie Kondo had no idea.
Only for Windows 8: Recovery Image
Almost all Windows 8/8.1 computers come with a recovery image, but the image may contain bloatware you don’t want reinstalled.
After you’ve uninstalled the software, use the recimg command to create a new image. When you enter this command, you’ll get a very detailed explanation of how to use it.
To use the recimg command, you must be an administrator, and you can only access the custom recovery image you create using the Windows 8 refresh feature.
System recovery has changed in Windows 10. Because Windows 10 systems do not include a recovery partition, it is more important than ever to back up your data.
Command and Control Your Windows Computer
This article can only scratch the surface of what the Windows command line has to offer. When all variables are considered, there are literally hundreds of commands.
For advanced support and troubleshooting, download Microsoft’s command line reference guide (in Edge or Internet Explorer).