How to Run Command Prompt With Desktop Shortcuts

By | January 13, 2022

Opening a command prompt and typing commands manually can be exhausting, but what if you could create a desktop shortcut to run commands whenever you wanted? Fortunately, while it’s not immediately clear how to do this, it’s possible on Windows 10 to create a Command Prompt shortcut.

Let’s explore how to create a Windows shortcut that runs the Command Prompt.

How to Open Command Prompt via Windows 10 Shortcut

To get started, let’s explore how to open a command prompt using a Windows 10 shortcut. It won’t do anything right away; You will still have to manually type the commands you want to perform. However, what we’re going to cover here will act as the basis for the other commands we’ll cover in this article.

First, we need to create a CMD shortcut. To do this, right-click on an empty space in File Explorer or on the desktop. Then, open New> Shortcuts.

When you click on this, Windows 10 will immediately show a pop-up window asking for the location. In this window, type “C:WindowsSystem32cmd.exe” then click Next.

This tells Windows to go into the system file and run the Command Prompt executable. If your Windows 10 installation is on another drive, replace “C:” with the drive you used for your OS.

After clicking Next, you can name the shortcut something easy to remember. Give it a name like “Open Command Prompt” and click Finish.

Now when you double click your new shortcut, Command Prompt appears.

How to Run Commands via Windows 10 Shortcuts

Now that we have the basics in place, let’s learn how to create a CMD shortcut with the built-in commands. If you want to create a new shortcut, repeat the steps above; however, if you want to edit the command you made earlier, just right click, click Properties, then add your new command below Target.

Now, let’s run the command via our shortcut. To do this, type “C:WindowsSystem32cmd.exe” /k followed by your command.

For example, “C:WindowsSystem32cmd.exe” /k echo hello world will tell the command prompt to print “hello world.”

You may see a strange “/k” in the middle of the command. This tells the command prompt to run what we type after, then keep it open so you can see the results.

If you prefer the command prompt to close immediately upon completion, replace this /k with /c instead.

How to Run Multiple Commands via Windows 10 Shortcuts

You can also referensi multiple commands together. Just add an ampersand (&) between each command to chain them.

For example, “C:WindowsSystem32cmd.exe” /k echo hello & echo world would print “hello,” then “world.” You don’t have to repeat /k or /c for each command; one at the start will do.

Examples of Useful Commands to Have Shortcuts

Now you have everything you need to run commands from shortcuts, whether you want to type commands manually or automatically run predefined ones. Having said that, let’s take a moment to explore some of the useful ways you can use this tool to make certain tasks easier.

Ping or Trace Route from Specific Website or IP

If the websites you visit frequently go down, or you want to check the health of a remote server, the ping and tracert commands are very useful. Ping lets you see how fast your connection is between you and the target, while tracert lets you see every step in the connection.

To set up an automatic ping command, enter “C:WindowsSystem32cmd.exe” /k ping followed by your target.

For example, “C:WindowsSystem32cmd.exe” /k ping www.google.com will tell you how quickly you can reach Google in milliseconds.

Likewise, using “C:WindowsSystem32cmd.exe” /k tracert followed by your target will show you every step taken between you and the server. Using this on Google will show you all the servers your connection visits before it reaches the website.

Requesting DNS Cache to Solve Connection Problems

If you keep having DNS connection issues, why not set up an automatic shortcut that bypasses your DNS cache? Just create a shortcut with “C:WindowsSystem32cmd.exe” /k ipconfig/flushdns and double-click it whenever DNS connection issues arise. You may even want to use /c for this command to close it when it’s done.

Check Your File System Health With Chkdsk and SFC

If you want to quickly check the performance of your file system, you can do so using Checkdisk (chkdsk) and System File Checker (SFC). Chkdsk scans your entire computer for errors, while SFC does the same only for your important system files.

If you want easy access to these tools, you can create a checkdisk shortcut with “C:WindowsSystem32cmd.exe” CHKDSK /f C:, and an SFC command with “C:WindowsSystem32cmd.exe “/k sfc / scannow.

Logoff, Restart or Shut Down Your Computer

Finally, did you know that you can log off, restart, and shut down your PC from the command prompt? They all use the same “shutdown” command, but the variable you pass the command determines the action you want to perform.

All of the following commands are activated with “C:WindowsSystem32cmd.exe” /k shutdown, so enter whatever you want to do. Then, add one of the following arguments to the end:

  • / l will exit the current user.
  • /r will restart the computer.
  • /r/o will restart the computer then boot back into the advanced startup options.
  • / s will turn off the computer.
  • /s / hybrid shut down the PC, then prepare it for a quick startup.
  • / h will put the computer into hibernation mode.
  • / a cancels the current shutdown sequence, as long as it was performed during the timeout period.
  • /n, when placed after a shutdown (/s) or restart (/r) command, determines how many seconds the PC will wait before performing that activity. Add a number after /t to specify the time; for example, /r/t 100 will restart the PC after 100 seconds have elapsed.

Using the Command Prompt in a Smarter Way

Constantly retyping commands can be exhausting, so why not create a shortcut that does the hard work for you? Now you know how to create a shortcut that, when double-clicked, will open a command prompt or automatically execute a command of your choosing.

Category: