Shortcuts are great for giving you quick access to files, apps, and folders. But did you know you can also use them to run Command Prompt commands?
Windows gives you all kinds of ways to run command prompt commands. Sure, you could open a Command Prompt window and just type the command. You could also create yourself a batch script (or a bash script or PowerShell script if that’s your thing). And frankly, if you’re planning on running more than one command or you need anything complex, writing a script is a better option. But for simple commands, why not just create a double-clickable shortcut instead? Here’s how to do it.
RELATED: 10 Ways to Open the Command Prompt in Windows 10
Create a shortcut by right-clicking anywhere in File Explorer or your desktop and choosing New > Shortcut.
In the Create Shortcut window, type your command using the following syntax:
The first part (the part in quotes) just calls cmd.exe to open the Command Prompt. The switch /k tells Command Prompt to issue the command that follows, and then stay open so that you can view results or type followup commands. You can also use the /c switch instead /k (use only one of the switches) if you want the Command Prompt window to close after issuing the command. And of course, the yourcommand part is the actual command you want to run.
RELATED: How to Scan for (and Fix) Corrupt System Files in Windows
For example, if you were creating a simple command to run the system file checker to find and fix problems with your system files, you’d type the following:
When you’ve created the command you want to use, click “Next.”
Type a name for the shortcut and then click “Finish.”
Now, you can run shortcut instead of firing up Command Prompt and typing the command manually each time.
Another clever thing you can do is pipe the results of a command to a text file (or other program). For example, say we wanted to run the command ipconfig /all , have the results saved to a file named ipconfig.txt on your desktop, and have the Command Prompt window close after running the command. We could use the following to make that happen:
If you use a single > for the piping command, Windows will overwrite the contents of the named file if the file already exists. If it doesn’t exist Windows will create the file. You can also use a double » instead to have Windows append the new information from the command to an existing file instead of overwriting the file. This is useful if you want to keep a history of the results of a command.
Once you have your shortcut set up, it’s easy to run a command anytime you need to. And while you might still want to use a script for anything more complicated, running a command from a shortcut is great for simple one-off commands like scanning for corrupt system files, finding your IP address, shutting down Windows without installing updates, and more.
RELATED: How to Scan for (and Fix) Corrupt System Files in Windows