Advertisement

Pin a batch file to the Start menu or taskbar in Windows 10

Sometimes you need to pin a batch file to the Start menu or taskbar in Windows. Unfortunately, the operating system doesn't allow you to do it out of the box. "Pin to Start" and "Pin to taskbar" context menu commands are missing in the context menu of File Explorer in Windows 10. Here is a quick workaround which will allow you to achieve the goal.

When you right click a batch file, you will see that the context menu does not contain the commands "Pin to Start" and "Pin to taskbar":
no pin context menu
As a workaround, you can create a shortcut with the following target:

cmd /c "path to your batch file"

This will execute the batch file and close the command prompt window. Double quotes are so that you can use long file names in the path.
If you use the following shortcut target:

cmd /k "path to your batch file"

Then the command prompt will remain open after the batch file finishes running.
When you right click such a shortcut, it will include the context menu commands to pin to Taskbar or Start!

Here is what you need to do.

  1. Right click on the Desktop and select the command "New -> Shortcut" from the context menu.Windows 10 new shortcut
  2. In the shortcut target, type the following text:
    cmd /c "full path to your batch file"

    In my example, it will be

    cmd /c "C:\Users\winaero\Desktop\test.cmd"

    shortcut target

  3. Name the shortcut and change its icon if you need:shortcut name
  4. Now, right click the shortcut and choose "Pin to Start" from the context menu:Windows 10 pin batch file to start

You are done. The result will be as follows:Windows 10 pinned batch file to start Windows 10 pinned batch file to start 2

That's it.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

33 thoughts on “Pin a batch file to the Start menu or taskbar in Windows 10”

  1. I tried this multiple times and {sigh} I can’t get it to work. The short cut gets created, but when I double-click it, the batch files doesn’t run… no errors… just doesn’t run.

    1. Try
      cmd /c “[path to batch].bat”
      instead of
      cmd /c “[path to batch].cmd”
      It worked for me.

  2. Fast Easy solution: Rename your .bat file to .exe and then drag to task bar. Then right click the shortcut on the taskbar, select properties, and rename back to .bat .. and rename the original file back to .bat

    1. I can confirm that this works, however it should be noted that you need to Shift+right click and not just right click.

    2. Michael Wonderland’s solution better – it allow to ping multiple bat or bat and command line in same time.
      Solution from the article dont allow to pin Command line shurtcut and .bat (because cmd.exe executable in both shortcuts).

    3. This method worked for me. If you want to put the link on Start, right click the .exe and click Pin to Start. Then, from Start, right click on the resulting button. Select “Open file location.” Right click on the file in the file explorer to get to properties.

  3. The bat file is not necessary. You can write the command directly in the “Type the location of the file” box of the shortcut creation wizard.
    Anyway, that is not enough. Right-clicking on the new shortcut still does NOT show the “pin to start menu” menú item. For that to happen you also have to:
    1) Move the shortcut to a subfolder of the “start menu” folder, which is located in “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu”.
    2) Use the search box in the taskbar to find the shortcut
    Then, right-clicking on on the search result should show the “pin to start menu” item.

    1. “The bat file is not necessary.”

      That’s nonsensical. This article is about how to pin a batch file.

      “You can write the command directly in the “Type the location of the file” box of the shortcut creation wizard.”

      What command? Again, this article is about how to pin a *batch file*. If you put the batch file location directly into the location, you can’t pin the shortcut … the whole point is that you need a .exe … cmd.exe for executing batch files.

  4. The most easy solution.
    Copy de direct acces to : C:\Users\[YOURUSER]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

    Then, you will see the .bat in the windows menu, right click and “pin to start menu” :)

  5. Thanks for this. Nowhere else mentions using cmd.exe, and most of the comments above are wrong, except the one about dragging the shortcut to the taskbar, which I needed because my shortcut doesn’t have “Pin to taskbar” in the context menu for some reason.

  6. Pingback: 5 Windows display tricks to help you focus - Gigarefurb Refurbished Laptops News
  7. Pingback: 5 Windows display tricks to help you focus - Daily News Observer
  8. Pingback: 5 Windows display tricks to help you focus – Persian Version
  9. Pingback: 5 Windows display tricks to help you focus – MNNOFA NEWS
  10. Pingback: 5 Windows display tricks to help you focus - TECH INSPIRED NEWS
  11. Just change the file extension to .exe, drag it to task bar, change it back to .bat file. after that, shift + right click the file on the task bar, properties, and change the .exe to .bat

  12. Thx a lot. I had to make a batch file solution to hibernate my pc ‘manually’ and was able to put the shortcut on the taskbar thanks to your suggestion.

    ::Run at elevated prompt
    @echo off
    if _%1_==_payload_ goto :payload

    :getadmin
    echo %~nx0: elevating self
    set vbs=%temp%\getadmin.vbs
    echo Set UAC = CreateObject^(“Shell.Application”^) >> “%vbs%”
    echo UAC.ShellExecute “%~s0”, “payload %~sdp0 %*”, “”, “runas”, 1 >> “%vbs%”
    “%temp%\getadmin.vbs”
    del “%temp%\getadmin.vbs”
    goto :eof

    :payload

    ::ENTER YOUR CODE BELOW::

    @echo OFF

    shutdown /h

  13. I prepared the following BAT script for the Send To context menu. This BAT file copies itself to the Send To folder, thus creating any file to click in the Send To context menu as a shortcut to the Start Menu\Programs.

    @echo off

    :: Pin To Start (Limitless) for the “Send To” context menu (by PureOcean, 2021-06-12)
    :: This BAT file copies itself to the SendTo folder, thus creating any file to click in the Send To context menu as a shortcut to the Start Menu\Programs. Even .BAT/.CMD files that Windows doesn’t support (That’s why it was prepared).

    IF EXIST “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\SendTo\%~nx0” (GOTO :PinToStart) ELSE (Copy “%~nx0” “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\SendTo\%~nx0” /y > nul && Echo %~nx0 added to the “Send To” context menu. && pause > nul && exit /b)

    :PinToStart
    powershell “$s=(New-Object -COM WScript.Shell).CreateShortcut(‘%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\%~n1.lnk’);$s.TargetPath=’%~f1′;$s.WorkingDirectory=’%cd%’;$s.Save()”

    1. Hi PureOcean,
      this seemed like a clever bit of code. It doesn’t fully work for Windows 10 Start Menu, though, even after fixing the single- and double-quotes that my system didn’t like (“ ” ‘ ’), however if this website is responsible my adjusted code below will be exactly the same! I’ll try anyway.

      The point is, it works as far as sending a shortcut of anything to the Windows Start Menu folder of course, but once there, it does not show up in the Start Menu, nor do you get any context menu to “Pin To Start”. Windows 10 does not like those shortcuts any better than it did before.

      It was very educational to study though, thank you for sharing the code, I will use it to build something else!
      Danny

      Adjusted quotes version:

      @echo off

      :: Pin To Start (Limitless) for the “Send To” context menu (by PureOcean, 2021-06-12)
      :: This BAT file copies itself to the SendTo folder, thus creating any file to click in the Send To context menu as a shortcut to the Start Menu\Programs. Even .BAT/.CMD files that Windows doesn’t support (That’s why it was prepared).

      IF EXIST “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\SendTo\%~nx0” (GOTO :PinToStart) ELSE (Copy “%~nx0” “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\SendTo\%~nx0” /y > nul && Echo %~nx0 added to the “Send To” context menu. && pause > nul && exit /b)

      :PinToStart
      powershell “$s=(New-Object -COM WScript.Shell).CreateShortcut(‘%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\%~n1.lnk’);$s.TargetPath=’%~f1′;$s.WorkingDirectory=’%cd%’;$s.Save()”

      Pause

  14. Follow my original method, and you will get .bat file{s} pinned in Taskbar. WORKS 100%

    Step 1: Create shortcut of your .bat file (for example in Desktop “C:\Users\youruser\Desktop\yourfile.bat”). So you will end up with “yourfile.bat – Shortcut.lnk” (you might not see extension “.lnk”).

    Step 2: Right Click your shortcut and change your Target field from: “C:\Users\youruser\Desktop\yourfile.bat” to: explorer “C:\Users\youruser\Desktop\yourfile.bat” – note: explorer is the explorer.exe app. You can also write the full Path: C:\Windows\explorer.exe, for no confusion.

    Step 3: Now Right Click your shortcut and now you can see the option Pin to Taskbar.

    Step 4: Right Click the pinned shortcut, and you will see two options: shortcut itself and unpin option. Right Click the shortcut and select Properties. From Target field delete “C:\Windows\explorer.exe” and leave only “C:\Users\youruser\Desktop\yourfile.bat”, and click OK

    Now you can delete your shortcut in Desktop, since now you have your standalone shortcut on Taskbar
    Optionaly, if you want to change Icon do Step 4, but now click “Change Icon…” button, and choose your custom Icon, from some other exe file or .ico file.

    That’s it!
    Now you have fully functional batch file shortcut on Taskbar

    1. Hi Carlso James,
      Yes, this works! I was sure by now (almost a year after your post) MS updates would have nipped this ability in the butt… in the same manner as the original profoundly obnoxious idea of “hey let’s prevent most things from pinning to Start at all!” Windows 10 Start Menu is halfway useless with such limitations. I was about to switch to only Open-Shell and other third-party software, but this helped so much. I do like the Start Menu look in 10, but you shared actual functionality. :)

      Although your solution is kind of a pain for many pins (100% not your fault) it absolutely works!

      NOTE: I did not get a Properties choice on right-clicking the item in Start Menu, only Resize and Open Location—but boom—open location and you can edit the shortcut there, including icon and name of batch file, as much as you like; it updates right away (no need to re-pin) and still working after I signed off/on again.

      Thank goodness we can still hack Windows back into a functional product. There are plenty of smart tools out there, I have put a lot of work into remodeling my entire system. I may even share what and how I did so I can help others, as well as remember for myself!

      THANK YOU, Carlso.
      Danny

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.