How to Run Command Prompt Commands from a Windows Shortcut
Right-click a blank area of the desktop., Click Shortcut. , Type %comspec% /k into the text box., Press the spacebar. , Type the command you want to run., Click Next. , Enter a name for the shortcut., Click Finish., Double-click the shortcut to run...
Step-by-Step Guide
-
Step 1: Right-click a blank area of the desktop.
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. ,, Whatever command you type after %comspec% /k is the one that will run when you double-click this shortcut.
For example:%comspec% /k ping www.google.com will ping www.google.com when you double-click the shortcut. %comspec% /k sfc scannow will scan all protected system files when you double-click the shortcut. ,, This is the text that will appear under the icon.
For example, if the shortcut pings Google, you could type ping google. , The shortcut is now on your desktop. , The command prompt window will appear, and you’ll see your command running. -
Step 2: Click Shortcut.
-
Step 3: Type %comspec% /k into the text box.
-
Step 4: Press the spacebar.
-
Step 5: Type the command you want to run.
-
Step 6: Click Next.
-
Step 7: Enter a name for the shortcut.
-
Step 8: Click Finish.
-
Step 9: Double-click the shortcut to run the command.
Detailed Guide
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. ,, Whatever command you type after %comspec% /k is the one that will run when you double-click this shortcut.
For example:%comspec% /k ping www.google.com will ping www.google.com when you double-click the shortcut. %comspec% /k sfc scannow will scan all protected system files when you double-click the shortcut. ,, This is the text that will appear under the icon.
For example, if the shortcut pings Google, you could type ping google. , The shortcut is now on your desktop. , The command prompt window will appear, and you’ll see your command running.
About the Author
Jean Cooper
Enthusiastic about teaching practical skills techniques through clear, step-by-step guides.
Rate This Guide
How helpful was this guide? Click to rate: