Opening the command prompt and entering a command manually can be tedious. What if you could create a desktop shortcut to execute commands whenever you want? Fortunately, although it's not immediately obvious how to do this, in Windows 10 it is possible to create a shortcut for the command prompt.
Let's examine how to create a Windows shortcut that does a command prompt.
How to open Command Prompt from Windows 10 shortcut
First, let's examine how to open Command Prompt using a Windows 10 shortcut. It won't do anything right away. You still have to enter the desired command manually. However, what we cover here serves as the basis for the other commands that we cover in this article.
First we have to create a CMD link. To do this, right-click in an empty area in File Explorer or on the desktop. Then go to New> Link.
When you click on it, a pop-up window will immediately appear in Windows 10 asking for a location. In this window, type "C: Windows System32 cmd.exe" and click Next one.
This tells Windows to go into the system files and run the command prompt executable. If your Windows 10 installation is on a different drive, replace the "C: " with the drive you are using for your operating system.
As soon as you click Next oneyou can call the link something memorable. Give it a name like "Open Command Prompt" and click Finished.
If you now double-click on your new shortcut, the prompt will appear.
How to run a command from Windows 10 shortcut
After understanding the basics, we'll learn how to create a CMD link with a command built into it. If you want to create a new shortcut, repeat the above steps. However, if you want to edit the command you created earlier, just right-click on it and click propertiesThen add your new command below T.Arget.
Now let's run a command through our shortcut. To do this, type "C: Windows System32 cmd.exe" / k followed by your command.
Example: "C: Windows System32 cmd.exe" / k echo hello world instructs the prompt to print "hello world".
You may notice the odd "/ k" in the middle of the command. This instructs the command prompt to do what we type afterwards and then remain open so that you can see the result.
If you want the prompt to close immediately, replace / k with / c instead.
How to run multiple commands from Windows 10 shortcut
You can also chain several commands together. Simply add an ampersand (&) between each command to concatenate them.
Example: "C: Windows System32 cmd.exe" / k echo hello & echo world outputs "hello" and then "world". You do not have to repeat / k or / c for each command. one at the start is enough.
Examples of useful commands as shortcuts
Now you have everything you need to execute commands from a shortcut, whether you type the command manually or automatically run a preset command. So take some time to explore some useful ways you can use this tool to simplify certain tasks.
Ping or track the route of a particular website or IP
If a website you visit frequently fails or you want to check the status of a remote server, the ping and tracert commands are often used. With Ping you can see how fast your connection is between you and the destination, while with tracert you can see every step in the connection.
To set up an automatic ping command, type "C: Windows System32 cmd.exe" / k ping followed by your destination.
At "C: Windows System32 cmd.exe" / k ping www.google.com you can find out, for example, how quickly you can contact Google in milliseconds.
If you use "C: Windows System32 cmd.exe" / k tracert followed by your destination, you will see all the steps that are performed between you and the server. If you use this on Google, you will see all the servers that your connection visits before it reaches the website.
To learn more about these commands, be sure to read the Windows wireless network commands
8 CMD commands to manage wireless networks in Windows
Clear the DNS cache to fix connection problems
If you still have problems with the DNS connection, set up an automatic link that clears your DNS cache. Simply create a shortcut to "C: Windows System32 cmd.exe" / k ipconfig / flushdns and double-click it every time a DNS connection problem occurs. You might even want to use / c on this command to close it when it's done.
Not sure what actually clears the DNS cache? Then be sure to read what DNS is and why it may no longer be available
What is a DNS server and why is it not available?
Check the condition of your file system with Chkdsk and SFC
If you want to quickly check how your filesystem works, you can use that too Check disk (chkdsk) and the System File Checker (SFC). Chkdsk scans your entire computer for errors, while SFC does only for your important system files.
If you simply want to access these tools, you can use a check disk shortcut with "C: Windows System32 cmd.exe" CHKDSK / f C: and an SFC command with "C: Windows System32 cmd.exe "create" / k sfc / scannow.
We covered both chkdsk and SFC in our manual on repairing a non-mountable boot drive
How to fix a non-mountable startup disk in Windows 10
Give it a try if you want to learn more about these commands.
Log off, restart the computer, or shut down the computer
Finally, did you know that you can log out of the command prompt, restart and switch off your PC? They all use the same shutdown command, but the variables you give the command define what action you want to take.
All of the following commands are activated with "C: Windows System32 cmd.exe" / k shutdown. Enter this regardless of what you want to do. Then add one of the following arguments at the end:
- / l will log off the current user.
- / r restarts the computer.
- / r / o restarts the computer and then starts again with the advanced startup options.
- / s turns off the computer.
- / s / hybrid shuts down the PC and prepares it for a quick start.
- / H puts the computer to sleep.
- /a cancels a current shutdown sequence as long as this occurs during the timeout.
- / tWhen placed after a shutdown (/ s) or restart (/ r) command, it determines how many seconds the PC should wait before performing this activity. Add a number after / t to define the time. For example, / r / t 100 restarts the PC after 100 seconds.
Use the command prompt smarter
Constantly re-entering commands can be tedious. 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, either opens the command prompt or automatically executes a command of your choice.
If you want to know what kind of commands you can use with your new trick, read the CMD prompts every Windows user needs to know
15 Windows Command Prompt (CMD) commands you need to know
Disclosure of partners: By purchasing the products we recommend, you are helping to keep the website alive. Continue reading.