• Insights

Useful Command Prompt Tricks

Anthony Hughs

3 min read

All Insights

Some Background

The history of Microsoft Windows is a long and winding one. Today the OS has splashy graphics, touch capabilities, tiles, and the built-in personal assistant Cortana. Its beginnings were much humbler and ran on a product called DOS, a command line interface where you had no fancy graphics, just the occasional image made from colored ASCII characters codes such as what is seen below:

Ascii Characters forming an 'image'
Ascii Characters Forming an Image

In fact, all the way until Windows XP – DOS was the underlying platform that Windows Consumer products ran on (Windows 3.1 to Windows Millenium Edition). Windows NT used a virtual version of DOS which the consumer products started doing starting with Windows XP (Windows Vista, Windows 7, Windows 8.x, and Windows 10). Nowadays, even though Windows no longer runs on DOS, there are still some handy tricks you can use in the virtual version of it. This blog post aims to share some of these commands along with how they can benefit users.  We’ll start with some of the more basic commands that any IT technician might already be aware of, and then move on to some advanced commands which might offer some additional benefit.

How to Open a Command Prompt Window

You can still access the command prompt in a few different ways. The easiest of which is holding down the Windows Key on your keyboard and press the letter “R” (shown below). Then type “cmd” in the ‘Open:’ field and press ‘OK.’

Windows+R

Then

run_cmd

This will open a command prompt window, like this:

cmd

From here, there are several commands you can type, each providing its own unique results. You will need to press the Enter key on your keyboard after every command entered in to the command prompt.

Find your computer name

Type “hostname” in the command prompt window to find your computer name.

View your IP Address

Type “ipconfig /all” to view your IP address information.

Release and renew your IP Address (at the same time)

Type “ipconfig /release & ipconfig /renew” to release your IP Address and obtain a new one.

release_renew

Flush DNS on your local computer

Sometimes computers, servers, and websites change their IP addresses and we have stale DNS records that are pointing us to the wrong place. This results in not being able to find the computer. If an IP address has changed, you can flush the DNS by typing “ipconfig /flushdns.”

flushdns

Find network/mapped drives connected to your computer

Type “Net Use” in to the command prompt and it will show you all the mapped/network drives to which you’re connected.

Find which folders are shared on your computer

Type “Net Share” to see the folder locations where each shared folder is located on your computer and what their ‘shared’ names are.

netshare

Run commands as different user

Occasionally Administrators may need to run commands on a computer while a person is logged in who does not have Administrative rights on their computer. In cases like this, type “runas /user:yourdomain\administrator cmd.”  You will need to replace ‘yourdomain’ with your actual domain name. You will then replace administrator with the actual user name of a Domain Administrator. Then replace ‘cmd’ with any command you want to run as Administrator. Typically, we use ‘cmd’ because this opens the Command Prompt as Domain Administrator, which makes it easy to run multiple commands with Administrator privileges.

The highlighted section of this screenshot shows that a new command prompt has been opened and is being run as the user specified. This highlighted Command Prompt is where we would execute higher level commands.

Easily access previously entered commands

There are two ways to access commands you’ve previously typed into your Command Prompt window. You can press the up or down arrows on your keyboard to cycle through them one at a time. You can also press the F7 key on your keyboard to show a graphic list and choose the command you want to run again (shown below).

How to find the model of your computer

Type “wmic computersystem get model” to find out exactly which model computer you are running (highlighted).

How to find the serial number of your computer

Type “wmic bios get serialnumber.” For example, On a DELL computer this would show your your ‘DELL Service Tag.’

wmicserial

I’ve given you some commands to get started. Each of the commands above has more uses, and there are many more commands out there. The command line interface is still rich with possibilities, even as Windows has evolved beyond it.