How To Perform Common Tasks in Windows Command Prompt

How to Use Windows Command Prompt
(Image credit: Tom's Hardware)

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. The command prompt was where we worked and we had to learn a few tricks to get the job done. Fast forward to today and we have complex graphical user interfaces that work extremely well, but sometimes the command prompt is just quicker.

In this how to, we have collected a number of common GUI tasks, and shown how the command prompt can be used to get the same job done. These commands will work with Windows 7,8,10 and 11.

Accessing the Command Prompt

1. Click on Start and search for cmd, click on Run as Administrator. With administrator powers you can do some damage, so double check what you are typing before you press the Enter key.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

Clearing the Command Prompt

The command prompt can sometimes become cluttered, but we can soon fix that by clearing the screen with the cls command. Type the command and press Enter to gain valuable space in your command prompt.

cls

Get Your Network Connection Details

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

We can easily get our network connection details via the Network and Internet section of Settings, but what if you need them in the command prompt? The ipconfig command provides us with our IPv4 and IPv6 addresses, DNS details and other basic networking information.

1. In the command prompt, type ipconfig and press Enter. This produces a basic overview of the network connections currently in use.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

2. In the same prompt type ipconfig /all and press Enter. Using ipconfig with the /all switch shows a detailed breakdown of all the active network interfaces. These include our Bluetooth adapter and a virtual Ethernet adapter for our Virtualbox VMs.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

Filtering Output With Findstr

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

Commands can generate a lot of output. So how can we filter out the noise and target the data that we need? Using the findstr command we can pass strings to search for in the output of a command.

Here is an example using the ipconfig /all command, piping the output via “|” to become the input of findstr, where we specify the search string in quotes. In this example we are searching for the Host Name of our machine.

ipconfig /all | findstr “Host Name”

The findstr command can be used with many different commands, and using extra pipes we can direct the output to other tools / applications.

Checking Your Connection

Part of testing a network is checking that we can connect to another machine and with ping we can check our internal and external connections.

To check an internal connection, we will need to know the IP address of a device on the network. For that you will need to scan for devices on your network. Once we have the IP address we can use ping to check the connection.

ping 192.168.0.8

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

To check 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

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

IP Address Release and Renewal

Sometimes we need to release or renew the IP address of an adapter and this can be easily done via the prompt.

1. Use ipconfig /release to release all active connections. This will release all connections, Ethernet, Wi-Fi and Bluetooth.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

2. Use ipconfig /release *Eth* to close all connections matching the “Eth”. This will close all Ethernet connections, but keep others open.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

3. Use ipconfig /renew to renew all IPv4 connections. This will force all of the adapters using IPv4 to renew their IP addresses.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

4. Use ipconfig /renew6 to renew all ipv6 connections.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

Managing Tasks from the Command Prompt

The Windows Task Manager is the place to manage running tasks on your system, but we can also manage tasks directly from the command prompt with tasklist and taskkill.

1. List all of the running tasks by entering the command and pressing Enter. This will produce a list of applications, memory usage and a Process ID (PID).

tasklist

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

2. Use findstr to filter the tasks. In our example we are looking for “Inkscape”.

tasklist | findstr “inkscape”

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

3. Use taskkill to kill the session using its PID. In our example Inkscape’s PID is 1544.

taskkill /PID 1544

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

File Associations

We take it for granted that when we click on a file, it opens in the correct application. While we can edit the default application for a file type via the GUI, we can also do this via the command prompt. The assoc command is how we list and add a file association.

1. List the current files and their associated applications using assoc, press Enter to run.

assoc

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

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

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

3. Associate CSV files to a text file, opened by Notepad. This is safer than opening the file directly in Microsoft Excel, where we can check the file before importing into Excel.

assoc .csv=txtfile

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

4. Repeat the search using assoc. You will now see that .csv files are linked to text files.

assoc | findstr csv

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

Saving to the Clipboard

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

Saving the output of a command to the clipboard can be a laborious task. Highlight the text, right click, copy and then paste into the document. But what if we could save the output on the fly? Using clip we can pipe 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

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

2. Open a text editor and paste the contents of the clipboard.

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

Detailed System Information

How to Use Windows Command Prompt

(Image credit: Tom's Hardware)

 If you need to know everything about your system then the systeminfo command is for you. This command will output information such as

  • Memory
  • CPU
  • Hotfixes
  • Network
  • BIOS

Run the command from the command prompt. The output can be piped to clip for easy reading in a text editor.

systeminfo

Automatically Reboot into the BIOS

If you want to make changes – switching your boot order, for example – using your computer’s UEFI setup program, then you either need to know the right key to hit to enter your BIOS. Or you can use this command to do it all for you.

shutdown /r /fw /f /t 0

The basic shutdown command can take a number of switches.

/r to reboot

/fw to boot the BIOS

/f to force applications to close

/t 0 to reboot now, with 0 referring to zero seconds.

Les Pounder

Les Pounder is an associate editor at Tom's Hardware. He is a creative technologist and for seven years has created projects to educate and inspire minds both young and old. He has worked with the Raspberry Pi Foundation to write and deliver their teacher training program "Picademy".

  • Ralston18
    And for those who are already very comfortable with the Windows Command Prompt and DOS - take a look at Powershell.

    There are quite a number of "Get" cmdlets that can be used to discover and present all sorts of system information.

    And Powershell can go far beyond just that.
    Reply
  • kbz.uy
    me typing: ipconfig /all | findstr “Host Name”
    Khaby Lame: hostname
    Reply