How to Run Command Prompt Commands from a Windows Shortcut

Method 1 of 2:

Creating a Desktop Shortcut

  1. How to Run Command Prompt Commands from a Windows Shortcut Picture 1
    Right-click a blank area of the desktop.[1]
  2. How to Run Command Prompt Commands from a Windows Shortcut Picture 2
    Click Shortcut.
  3. How to Run Command Prompt Commands from a Windows Shortcut Picture 3
    Type %comspec% /k into the text box.
    1. The -k flag keeps the command prompt window open after the command is run. You can remove the flag if you prefer the window closes right away.
  4. How to Run Command Prompt Commands from a Windows Shortcut Picture 4
    Press the spacebar.
  5. How to Run Command Prompt Commands from a Windows Shortcut Picture 5
    Type the command you want to run. Whatever command you type after %comspec% /k is the one that will run when you double-click this shortcut. For example:[2]
    1. %comspec% /k ping www.google.com will ping www.google.com when you double-click the shortcut.
    2. %comspec% /k sfc scannow will scan all protected system files when you double-click the shortcut.
  6. How to Run Command Prompt Commands from a Windows Shortcut Picture 6
    Click Next.
  7. How to Run Command Prompt Commands from a Windows Shortcut Picture 7
    Enter a name for the shortcut. This is the text that will appear under the icon.
    1. For example, if the shortcut pings Google, you could type ping google.
  8. How to Run Command Prompt Commands from a Windows Shortcut Picture 8
    Click Finish. The shortcut is now on your desktop.
  9. How to Run Command Prompt Commands from a Windows Shortcut Picture 9
    Double-click the shortcut to run the command. The command prompt window will appear, and you'll see your command running.
Method 2 of 2:

Creating a Keyboard Shortcut

  1. How to Run Command Prompt Commands from a Windows Shortcut Picture 10
    Create a desktop shortcut for the command. A keyboard shortcut is a combination of keyboard keys you press to run a command or program. To create one for a command line command, make sure you've already created a desktop shortcut.[3]
    1. Keyboard shortcuts will follow the format Ctrl+Alt+[other key].
    2. You'll be able to choose a letter, number, or punctuation key as the 'other key.' For example, b, ., 3.
  2. How to Run Command Prompt Commands from a Windows Shortcut Picture 11
    Right-click the desktop shortcut.
  3. How to Run Command Prompt Commands from a Windows Shortcut Picture 12
    Click Properties. The 'Shortcut' tab of the Properties screen will appear.
  4. How to Run Command Prompt Commands from a Windows Shortcut Picture 13
    Click into the 'Shortcut Key' box.
  5. How to Run Command Prompt Commands from a Windows Shortcut Picture 14
    Press a letter, number, or punctuation key. The text box will fill with the entire shortcut using the key you press.
    1. For example, if you press p, the text in the box will change to Ctrl + Alt + P.
    2. If you create multiple keyboard shortcuts, make sure not to use the same key twice.[4]
  6. How to Run Command Prompt Commands from a Windows Shortcut Picture 15
    Click OK. You'll now return to the desktop.
  7. How to Run Command Prompt Commands from a Windows Shortcut Picture 16
    Press Ctrl+Alt+[other key] to run the command. The command prompt window will appear, running the command you set up in the desktop shortcut.
4.3 ★ | 4 Vote

May be interested

  • How to Open Folders in CMDHow to Open Folders in CMD
    do you need to access something from the command prompt or the windows command prompt? although it looks classic, this program is really easy to use if you know some basic commands. today's tipsmake will show you how to use the 'cd' command to open a folder in windows command prompt. besides, you will also know more great tips to instantly open command prompt in any folder on windows file explorer.
  • How to Change Directory in Command PromptHow to Change Directory in Command Prompt
    this article shows you how to change folders in the command prompt program on a windows computer. to change commands in command prompt, you must use an administrator account.
  • How to run multiple commands at once in CMDHow to run multiple commands at once in CMD
    command prompt is useful software for you to perform special tasks in windows. during use, there will be times when you need to run many commands simultaneously. 
  • How to open Command Prompt during Windows installationHow to open Command Prompt during Windows installation
    opening command prompt while you install windows will help you use commands in cmd such as checking drive health, converting standard mbr - gpt and many other benefits,
  • Summary of the common Run CMD commandsSummary of the common Run CMD commands
    instead of performing manual and direct access operations on windows, we can replace existing cmd commands for faster access.
  • How to use Xcopy command in Command PromptHow to use Xcopy command in Command Prompt
    knowing how to use xcopy command in command prompt, you will easily use commands in cmd professionally. in particular, the xcopy command is extremely useful for those who copy and copy data on the computer.
  • How to Add an 'Open Command Prompt Here As Administrator' Shortcut to the Context Menu in Windows 7 and Windows VistaHow to Add an 'Open Command Prompt Here As Administrator' Shortcut to the Context Menu in Windows 7 and Windows Vista
    in windows vista and windows 7, when you want to open a command prompt starting with a certain path, this can be a tedious process and sometimes you'll notice that some programs won't run from the command prompt at all, because they...
  • Add Command Prompt to Power User Menu on Windows 10Add Command Prompt to Power User Menu on Windows 10
    on windows 10 build 14971, microsoft replaced command prompt and command prompt (admin) with windows powershell. according to microsoft, this change will bring the best command line experience to users. but in fact, users prefer to use command prompt rather than using powershell.
  • Combine all the most basic AutoCAD commandsCombine all the most basic AutoCAD commands
    using autocad shortcut commands helps to manipulate faster. if you do not know all the cad commands, please see the summary of autocad commands that we have done below.
  • Instructions for using Command PromptInstructions for using Command Prompt
    deep in windows is a command-line world that is obscure. in this article, we will show you how to solve errors and make your computer more secure.