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 Use CMD (Beginner)Photo of How to Use CMD (Beginner)
    there is an easy way to impress your friends. including some basic commands and even a hacking tutorial, this is the perfect place to start. open command prompt. head over to the start menu. search 'cmd' there.
  • How to Open Command Prompt with a Keyboard Shortcut (Windows 8, 8.1, and 10)Photo of How to Open Command Prompt with a Keyboard Shortcut (Windows 8, 8.1, and 10)
    this article explains the simple steps for opening command prompt via your keyboard. press and hold the key.
  • How to Add New Options to Right Click Menu in WindowsPhoto of How to Add New Options to Right Click Menu in Windows
    the right-click menu of windows is perhaps the most widely used feature of the operating system. apart from enabling you to add new folders, cut, copy and paste files from one location to the other, you can add more options to the...
  • How to Unblock Command Prompt AnywherePhoto of How to Unblock Command Prompt Anywhere
    have you ever been at school and discovered that the it administrators blocked the command prompt? or did you try to do a command and it says 'access is denied'? this article will explain how to bypass these restrictions using simple...
  • How to Hide a File in an Image FilePhoto of How to Hide a File in an Image File
    this wikihow teaches you how to hide one or more files inside of an image file on a computer. you can do this on both windows and mac computers. copy the the file(s) and the image to your desktop. select the files you want to hide, press ,...
  • How to Fix Full Screen Command PromptPhoto of How to Fix Full Screen Command Prompt
    in windows xp, you can quickly set the command prompt to full-screen mode with the press of a key. with windows vista, 7, and 8, the full-screen option has been removed. this is due to the changes microsoft made to the display drivers in...