The Windows Command Prompt is like Greek or Latin to most people. The average Windows user dreads seeing it because he assumes that he needs to know computer programming to do anything from that point on. That’s not at all true. While the Command Prompt is certainly useful for developers to execute complex commands without the need for a separate user interface (UI), there are actually lots of commands that normal Windows users will find extremely helpful.
Let’s start at the beginning:
How to Launch Command Prompt
Did you know that there are at least 10 different ways to launch the Command Prompt, depending on which version of Windows you’re using? Let’s look at a couple of them.
Elegant Themes - The most popular WordPress theme in the world and the ultimate WordPress Page Builder. Get a 30-day money-back guarantee. Get it for Free
Run >> cmd (or cmd.exe)
This is probably the quickest way to access Command Prompt. Simply click on Windows + R to open the Run window, and then type either cmd or cmd.exe to launch Command Prompt. This method works on Windows 7, Windows 8 and 8.1, and Windows 10.
If you want to run Command Prompt as the administrator, then try this method below:
Find Command Prompt using the Search function. Type “command prompt” in the search field, and when you see the program on the list, right-click it to Run as Administrator. There are several commands that require administrator rights to be executed, as you will see below.
Now let’s look at 10 useful Windows commands that you can use in Command Prompt.
1. Create a WiFi Hotspot
If you want to share your device connect to other mobile devices, simply enter the following commands. This is for Windows versions before Windows 10. The latest version has a built-in feature to enable a hotspot.
netsh wlan set hostednetwork mode=allow ssid=Youthotspotname key=yourpassword
Replace the ssid and key values with the name of your WiFi and the password. It will now be enabled. To start the WLAN, execute this next command:
netsh wlan start hostednetwork
When you’re all done, end the session with this command:
netsh wlan stop hosted network
2. Find your License Key
To retrieve your license key for your Windows installation, use the following command:
wmic path softwarelicensingservice get OA3xOriginalProductKey
3. Find your IP Address
If you need your IP address for any reason, the quickest way is to get it from Command Prompt with a simple command:
It will show you the IP address of your router’s web interface. To see more details of your various adapters, use the following:
4. Scan your System Files for Issues
To let Windows do a scan of all your system files for various types of problems, you can use the following command:
If there are any issues found, your Windows system file checker will attempt to rectify them.
5. Change a file association
If you find that certain types of files aren’t able to get associated with the appropriate program to open them, you can manually change the association with the following command:
Replace ‘ext’ with the extension of the file and enter the program name after the “=” sign. If you want to just see the various file associations, use this:
6. Compare differences between two text files
For coders and writers working with .txt or .doc/.docx files, it’s very useful to know if there are any differences between two text documents where the content appears to be identical. To have Command Prompt display the differences, you can use the “fc” command as follows:
fc “C:\Program Files (x86)\document1.doc” “C:\Program Files (x86)\document2.doc”
There are also variations of the “fc” command:
fc /b – only compares binary output
fc /l – only compares ASCII text
fc /c – ignores letter casing
7. Create a recovery image
When you need to reinstall Windows at a later time, it’s useful to have a recovery image created in a specific directory. However, all the bloatware apps that are on your system will first need to be removed, and you can install your own desktop apps. Once the apps are in place, you can create a fresh recovery image using this command:
recimg /CreateImage C:\CustomRefreshImages\Image1
You can change the location as per your preference. The next time you refresh or reset your PC, the system will use the custom image that you created.
Note: This only works on Windows 8 and Windows 8.1 desktops. On Windows 8.1 tablets, after Microsoft brought in the “WIMboot” option, this command no longer works. It also does not work on the Windows 10 environment.
8. Remove a virus from a USB drive (Windows 10)
This is an easy way to remove a virus from an infected USB. First, let’s see how to clear the attributes of a virus file, and then delete it altogether using Command Prompt. You may want to copy any important files to another location before doing this.
First, change the directory by using F: or whatever the name of the removable USB drive.
Next, use the following command to list all the virus files:
This will list all the files in the USB drive. Now look for one of these files:
- New Folder.exe
These are typical virus files, so now you need to remove their attributes. Use the command below:
attrib -r -a -s -h *.*
-r will remove read-only files
-a will remove the archive file
-s will remove the system file
-h will remove the hidden file
*.* will specific that you want to remove those for all files with any type of extension
So far you’ve only removed file attributes for all files. You can now proceed to delete the virus file with this command:
Replace autorun.inf with the virus file name.
Now run the “attrib” command again, and you’ll see that the file has been successfully deleted.
If you simply want to delete all files with a particular extension, use:
9. Reset a User Account Password
At times, you may face a situation where you still have admin rights to your computer but a particular user account password has been forgotten. Alternatively, you may want to change the password for a particular account.
To see all user accounts, use the following command as administrator:
To change the password for a user, execute this command:
net user user_name new_password
Replace user_name with the user account to be modified, and replace new_password with a password of your choice. Hit Enter and the password will instantly be changed. You can now log out of the admin account and login to the user account with the different password. There are also several software applications that you can use if you want to completely reset the password.
10. Check port status for all peripheral connections
If you’re trying to troubleshoot peripheral devices and their connections to your PC, this command will be very useful:
This will display all ports, their IP addresses and their status – closed/established/listening. This is especially useful if you’re attempting to locate a malicious connection after suspecting a Trojan infection.
These 10 useful Windows Commands for Command Prompt will give you a lot more control over your Windows environment using the humble but powerful command line.