How To Perform Common Tasks in Windows Command Prompt
Windows is much more than a graphical user interface. For those of us old enough to remember, we started our PC journey with MS-DOS and then Microsoft Windows. We were working on the command prompt and had to learn a few tricks to get the job done. Fast forward to today and we have complex graphical user interfaces that work very well, but sometimes the command prompt is just faster.
In this guide, we’ve collected a number of common GUI tasks and shown how Command Prompt can be used to accomplish the same task. These commands work with Windows 7, 8, 10 and 11.
Access to the command prompt
1. Click Start and search for cmd, click Run as administrator. You can do some damage with administrative privileges, so double-check what you’re typing before hitting enter.
Delete the prompt
The command prompt can get cluttered at times, but we can fix that soon by clearing the screen with the cls command. Type the command and press Enter to free up valuable space in your command prompt.
cls
Get your network connection details
We can easily get our network connection details from the Network & Internet section of Settings, but what if you need them in Command Prompt? The ipconfig command gives us our IPv4 and IPv6 addresses, DNS details, and other basic network information.
1. Enter at the command prompt ipconfig and press Enter. This gives you a basic overview of the network connections currently in use.
2. In the same command prompt, type ipconfig /all and press Enter. Using ipconfig with the /all switch shows a detailed breakdown of all active network interfaces. This includes our bluetooth adapter and a virtual ethernet adapter for our virtualbox VMs.
Filtering the output with Findstr
Commands can generate a lot of output. So how can we filter out the noise and target the data we need? We can use the findstr command to pass strings to search for in the output of a command.
Here’s an example using the ipconfig /all command, with the output being piped with “|”. to become the input of findstr where we specify the search string in quotes. In this example we are looking for the hostname of our machine.
ipconfig /all | findstr “Host Name”
The findstr command can be used with many different commands, and with additional pipes we can direct the output to other tools/applications.
checking your connection
Part of testing a network is to verify that we can connect to another computer, and ping allows us to verify our internal and external connections.
To verify an internal connection, we need to know the IP address of a device on the network. To do this, you need to scan for devices on your network. Once we have the IP address, we can use ping to verify the connection.
ping 192.168.0.8
To verify an external connection, we can use ping with an external IP address. Our go-to IP address is one of Google’s DNS servers.
ping 8.8.8.8
Release and renewal of IP addresses
Sometimes we need to release or renew an adapter’s IP address and this can easily be done from the command prompt.
1. Use ipconfig /release to release all active connections. This will unblock all connections, Ethernet, Wi-Fi and Bluetooth.
2. Use ipconfig /release *Eth* to close all connections that match “Eth”. This closes all Ethernet connections but leaves others open.
3. Use ipconfig /renew to renew all IPv4 connections. This forces all adapters using IPv4 to renew their IP addresses.
4. Use ipconfig /renew6 to renew all IPv6 connections.
Manage tasks from the command prompt
Windows Task Manager is where you manage running tasks on your system, but we can also manage tasks directly from Command Prompt using Tasklist and Taskkill.
1. List all running tasks by typing the command and pressing Enter. This creates a list of applications, memory usage, and a process identifier (PID).
tasklist
2. Use findstr to filter the tasks. In our example we search for “Inkscape”.
tasklist | findstr “inkscape”
3. Use taskkill to end the session with its PID. In our example, Inkscape’s PID is 1544.
taskkill /PID 1544
File Associations
We assume that when we click on a file, it will open in the correct application. While we can edit the default application for a file type from the GUI, we can also do it from the command prompt. We use the assoc command to list and add a file association.
1. List the current files and their associated applications with assoc, press Enter to run them.
assoc
2. Search for specific file associations using findstr and a string to search for. In our example, let’s search for the application associated with CSV files.
assoc | findstr csv
3. Associate CSV files with a text file opened by Notepad. This is more secure than opening the file directly in Microsoft Excel where we can review the file before importing it into Excel.
assoc .csv=txtfile
4. Repeat the search with assoc. You will now see that .csv files are associated with text files.
assoc | findstr csv
Save to clipboard
Saving the output of a command to the clipboard can be a tedious task. Highlight the text, right-click, copy, and then paste into the document. But what if we could save the output on the fly? With clip we can direct the output of a command to the clipboard, from where we can paste it into a document.
1. Run the assoc command and pipe the output to the clipboard. The output of the command is redirected to the clipboard.
assoc | clip
2. Open a text editor and paste the contents of the clipboard.
Detailed system information
If you need to know everything about your system, then the systeminfo command is for you. This command outputs information such as
- memory
- CPU
- hot fixes
- network
- BIOS
Run the command at the command prompt. The output can be directed to a clip for easy reading in a text editor.
systeminfo
Automatic reboot in BIOS
If you want to make changes using your computer’s UEFI setup program — like changing your boot order — you either need to know the correct key to press to get into your BIOS. Or you can use this command to do everything for you.
shutdown /r /fw /f /t 0
The basic shutdown command can take a number of switches.
/r to restart
/fw to boot the BIOS
/f to force close applications
/t 0 to restart now, where 0 refers to zero seconds.