15 Brilliant Command Prompt – CMD Tricks You Might Not Know About

Command Prompt is one of the most useful applications on your Windows PC. The list of what you can do with this tool is endless – but we were able to shortlist some of the best CMD tricks that you can do on your Windows PC. We’re sure many of these commands will help you save a lot of time!

Best CMD Tricks for Windows

Before we get started, here are a few things you need to keep in mind.

  • While executing any of the commands below, make sure to open Command Prompt as an administrator. Right-click on the app, and select ‘Run as administrator’
Choose Run as administrator 2
  • There will be several instances where you need to enter the path of the file or folder into a command (file_path, or folder_path). Make sure to right-click on a file or a folder and select ‘Copy as Path’ to derive the path.
Copy as path option in File Explorer
  • Please proceed at your own risk, and execute these commands carefully. If not, you may affect the functionality of your Windows PC.

With that in mind, here are some useful command prompt commands that we want to show you!

1. Check Wi-Fi Password Using CMD

Did you forget the password of a previously connected Wi-Fi network on your Windows PC? Here’s how you can use Command Prompt to check the Wi-Fi password.

Step 1: Enter the following command on CMD.

netsh wlan show profiles

Step 2: You will see a list of Wi-Fi networks that are connected. Now, enter the below command, and replace NETWORK_NAME, with the name of the network you are searching the password for.

netsh wlan show profile name="NETWORK_NAME" key=clear

The ‘key component’ is the password for the Wi-Fi network.

Key Content

2. Check System Uptime


System uptime refers to the duration for which a computer has been continuously running without a restart. Enter the below command to find the system uptime using CMD on your Windows PC. Wait for the information to load, and you will be able to see the system boot time.

systeminfo | find "System Boot Time"

3. Empty Recycle Bin

You can also easily empty your recycle bin on your Windows PC using CMD. Enter the command below to instantly delete all the files in the recycle bin!

rd /s /q C:\$Recycle.Bin

4. Check the Network Ping

The ping command in CMD is a network utility that sends a small packet of data to a specific IP address or domain name to test the connection and measure the time it takes for the data to travel to the target and return. It measures the round-trip time for data packets to travel to a destination and back, indicating network latency or responsiveness.

Enter the following command on CMD while your PC is connected to the internet,

ping www.google.com
Ping CMD

5. Hide a File or Folder

You can also hide a file or a folder using Command Prompt on your Windows PC.

To hide a file, enter the following command.

attrib +h file_path

Replace file_path with the path of the file.

To hide a folder, use the following command. Replace folder_path with the destination path of the folder.

attrib +h folder_path
Hide File

Find Hidden Files

Hidden files or folders won’t be visible in File Explorer unless you’ve enabled the option to view hidden items. Go to the “View” tab in File Explorer in the destination where the file was initially present, and check the “Hidden items” box. However, do note that the hidden file/folder will be present in the same destination – except that it won’t be visible.

Tap on Hidden Items

Unhide Files

To unhide a file, enter the following command.

attrib +h file_path

Replace file_path with the path of the file.

To unhide a folder, use the following command. Replace folder_path with the destination path of the folder.

attrib -h folder_path
Unhide File

Alternatively, you can also right click on the hidden file or folder, and select Properties. Uncheck the hidden option to unhide the file/folder.

6. Check Command Prompt History

It is easy to get lost between the commands you’ve entered and the responses and output from the CMD tool. Here’s how you can easily access the history on Command Prompt.

There is a keyboard shortcut to view the history on CMD quickly. You can hold the F7 key or hold the ‘Fn’ key with F7 to access the history of your commands. It will appear in the form of a dialog box.

You can use the up and down arrow keys to navigate through your commands. Hit the enter key to execute the highlighted command.

Command Prompt History from Shortcut

7. Open a File Using CMD

Here’s how you can easily open a file using Command Prompt on your Windows PC.

Step 1: Type cd, followed by file path, and hit enter.

cd "folder_path"

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Note: Ensure to enter all the paths within double quotes.

Enter Folder Path

Step 3: Next, enter the file name and its extension in double quotes.

The name of the file we are using is “Sample Image” and its extension is “.png”.

Step 4: Hit the enter key, and the file will open.

Open File in CMD

8. Move or Copy Files or Folder Using CMD

You can easily move a file or a folder from one location, or copy them to another using CMD. Here are some of the CMD tricks that help you do so!

Type cd and paste the path of the file you want to copy or move. Hit the enter key.

cd "folder_path"

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Enter Folder Path 2
  • To copy a file to a different location, type copy and the source file’s name and the destination folder’s path. Once done, press enter.
copy "filename.extension" "destination_path"

Our file is “Sample Image.png” and the destination path is “C:\Users\rsupr\OneDrive\Documents”.

Note: Ensure to enter all the paths, the filename, and its extension within double quotes.

File Copied

Note: If a file of the same name exists in the destination folder, you will receive a prompt whether you want to overwrite the file or abort the process. Type Y (yes) to overwrite or N (no) to abort, and hit enter.

Copy Prompt
  • To move a file to a different location, type move, followed by the source file’s name and the destination folder’s path. Now, hit enter.
move "filename.extension" "destination_path"

Our file is “Sample Image.png” and the destination path is “C:\Users\rsupr\OneDrive\Documents”.

Note: Ensure to enter all the paths, the filename, and its extension within double quotes

Move File Using CMD 1

Note: If a file of the same name exists in the destination folder, you will receive a prompt whether you want to overwrite the file or abort the process. Type Y (yes) to overwrite or N (no) to abort and hit enter key.

Move Prompt

9. Delete a File Using CMD

Here’s how you can delete a file using CMD on your Windows PC.

Step 1: Type cd, followed by the file’s path you want to delete. Hit the enter key.

cd "folder_path"

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Note: Ensure to enter all the paths within double quotes.

Enter Folder Path 1

Step 2: Type del followed by the name of the file you want to delete. Hit the enter key.

Ensure to enter the filename and its extension within double quotes. The name and extension of the file we are using are “Sample Image” and “.png”.

Delete File in CMD

10. Run a System File Checker

The Windows System File Checker – SFC scan is a tool you can use on Command Prompt that detects any corrupted files on your PC. Once detected, it attempts to repair and restore the file. This is a tool that you can use if you are encountering any problems while using your Windows PC.

Type the following command :

SFC /scannow

As the system scan begins, you can see its progress. Once the system scan is complete, you will see whether it is successful or not.

11. Remove Bluetooth Devices Using CMD

If you’re unable to remove a Bluetooth device from your Windows PC, CMD can help you get rid of such stubborn devices. Here’s how :

First, we need to find a parameter called ‘Device instance path’ that helps Command Prompt identify your Bluetooth device.

Step 1: Open Device Manager from the Start menu on your Windows PC.

Device Managers

Step 2: You will see a list of device categories. Click on Bluetooth.

Step 3: Find the device that you want to remove.

Right Click on Device

Step 4: Right-click on the device. Click on Properties.

Tap on Properties of Device

Step 5: Go to the Details tab. Select the dropdown menu of Property and select Device Instance path.

Step 6: Select and copy the value of the Device instance path.

Step 7: Now, open Command Prompt as an Administrator.

Step 8: Enter the following command:

pnputil /remove-device "Device_Instance_path"

Replace Device_Instance_path with the value you just copied to your clipboard. Make sure you paste it within the double quotes.

Step 8: Hit the enter key once you add the command. Windows will remove the Bluetooth device.

Device Removed

12. Copy CMD Output to Clipboard

Depending on your command, CMD might give out an output with a large number of characters. Copying these characters can be difficult with the selection tool. Therefore, you can make use of this simple command to copy CMD output to clipboard.

Run your desired command in the Command Prompt window whose output you want to copy. Then, use the pipe (|) character followed by clip to copy the output. Take a look at the example below.

Copy output to clipboard

13. Terminate Processes Using CMD

If you want to fully shut down an app or a process, here’s how you can terminate a process using the ‘taskill’ command in CMD.

Step 1: Use the tasklist command to list all running processes and note down the name of the process you want to terminate.

Tasklist

Step 2: Use the taskkill command followed by /IM (Image Name) and the process name to terminate it. At the end, add the /F command to force the process to terminate.

taskkill /IM process_name.exe /F
Taskill

14. Delete Temporary Files

It’s necessary to delete temporary files on Windows to free up disk space, enhance system performance, and prevent potential issues caused by accumulated junk files.

Enter the following command to delete the local temporary (%temp% folder) files in Windows.

del /q /s %TEMP%\*

15. Delete Internet Cache Files

Depending on your web browser, enter the following command to delete the junk files created by websites and online data that is stored on your PC.

  • For Microsoft Edge :
del /q /s /f %LOCALAPPDATA%\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\AC\INetCache\*
  • For Google Chrome :
rd /s /q "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Cache"

Bonus: Best CMD Shortcuts

While the above commands help you execute several tasks with ease in CMD, you also need to know a few shortcuts to use the tool itself efficiently. Here are ten keyboard shortcuts in CMD that can help you use the tool with ease!

  • Ctrl + C: Terminate the current command or process.
  • Ctrl + V: Paste the text into the Command Prompt.
  • Ctrl + A: Select all text in the Command Prompt window.
  • Ctrl + Shift + Arrow Keys: Highlight text in the Command Prompt window.
  • Ctrl + F: Open the “Find” dialog to search for text.
  • Ctrl + Up Arrow: Scroll through previously entered commands.
  • Ctrl + Down Arrow: Scroll forward through previously entered commands.
  • Tab: Auto-complete file or folder names.
  • F7: Display a list of previously executed commands for selection.
  • Alt + Enter: Toggle between full-screen and windowed mode.

Cool CMD Tricks and Commands to Use Your PC Efficiently

We hope this article helps you find new and fun ways to use Command Prompt on your Windows PC with these CMD tricks and hacks. Well, if you ever dreamt of looking like a computer wizard – this is your chance, and use these CMD commands to look like a hacker! What’s your favorite command from this list? Do let us know in the comment section below!

Was this helpful?

Thanks for your feedback!

Last updated on 30 November, 2023

The article above may contain affiliate links which help support Guiding Tech. The content remains unbiased and authentic and will never affect our editorial integrity.