Undetectable Humanizer: Lifetime Subscription
Transform AI-Generated Text into Human-Like, High-Ranking Content & Bypass Even the Most Sophisticated AI Detectors
Get 95% Deal

How to run command prompt commands from desktop shortcuts in Windows

Martin Brinkmann
Jun 5, 2015
Windows
|
6

If you need to run command prompt commands regularly in Windows, it may be useful to save the command somehow so that you can run it whenever the need arises without having to type it all out again.

While you can use batch files for that, it is also possible to use shortcuts instead. The core difference between the two options is that you can only run a single command using shortcuts while you can run a series of commands and get better customization options when using batch files.

Adding commands as desktop shortcuts in Windows is a straightforward easy process that requires zero knowledge of batch files and little knowledge about the commands you want to run.

Basically, you are using the command %comspec% /k for that followed by the command that you want to run. For instance, if you wanted to display the contents of drive c you would use the command %comspec% /k dir c: for that.

Comspec is a system variable that defines the command interpreter used on the system. If you have not modified that, cmd.exe is being used. The k parameter of cmd.exe keeps the execution window open after running the command. If you don't require that, you may replace it with /c which terminates it.

Adding the shortcut

To add a new shortcut, right-click on a blank spot on your desktop and select New > Shortcut from the context menu.

Type the command that you want executed whenever you run the shortcut, for instance %comspec% /k dir c: or any other command in that format.

comspec

Click the next button and name the shortcut. The default name is set to cmd.exe which you may want to change, especially if you want to add multiple command prompt shortcuts on the system.

Once done run the shortcut to verify that it is working correctly. It is easiest with the /k parameter as you see the output in the command prompt window. Once you have verified the correctness, you may remove the /k parameter if you don't need to see the output on the screen.

Closing Words

Using shortcuts to run commands on the command prompt can be quite useful, for instance if you need to run a command regularly. This can be something simple as the directory command listed above but also advanced commands that turn features on or off for example.

Now You: Have another tip? Feel free to share it with everyone else in the comment section below.

Summary
How to run command prompt commands from desktop shortcuts in Windows
Article Name
How to run command prompt commands from desktop shortcuts in Windows
Description
Find out how to run command prompt commands using shortcuts in the Windows operating system.
Author
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. Gurmeet said on June 18, 2015 at 8:18 pm
    Reply

    The solutions turned out to be very simple.
    1. Open text edit

    2. Write the command, save
    as .bat.

    3. Double click the file created and the command automatically starts running in command-prompt.

  2. Saranathan said on June 14, 2015 at 2:29 pm
    Reply

    Useful article

  3. Alex said on June 8, 2015 at 8:49 am
    Reply

    I found out that recently that you can type in commands into Explorer’s path bar, it’s much faster than creating shortcuts, also command history is saved in the list revealed by Alt+Down. It works in Win 7 and 8, in XP it’s a bit different and not always require you to type cmd.exe before the command itself.

  4. Anonymous said on June 8, 2015 at 4:06 am
    Reply

    Hi What I have done is went to Windows system32 folder, right click cmd command send to desktop. Easy

  5. RossN said on June 6, 2015 at 12:03 am
    Reply

    WinKey+R > net stop wuauserv

    Who wants to restart their computer after Windows Updates complete? Or get nagged to do so? I shut my computer down each day. It may be different for those who use the hibernate or standby options though.

    WinKey+R > %temp%
    (then delete all files older than 24 hours old)

    It’s amazing how many people don’t have Windows doing automatic maintenance, and their computer gets clogged up (and slowed down) with thousands of temporary files.

  6. Ryan Jones said on June 5, 2015 at 1:55 pm
    Reply

    Despite the fact that yes you can run commands as a shortcut (which is really all shortcuts are) I think the route of going with a batch file or vbs script for generic tools is probably the more economically and desktop friendly way of approaching it. Decreases clutter and can run a series of commands in succession. Single command though wouldn’t hurt.

    shutdown /f /s /t 0

    Probably one of my more used commands on anything greater than Windows XP, when the option of shutdown includes “install updates”, that’s a quick bypass. So yeah I can see a use for it, but would suggest batch more often.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.