How to Pin a Batch File to the Windows Taskbar

windows won’t let you pin .bat files directly to the taskbar – dragging one there or right-clicking and selecting “Pin to taskbar” doesn’t work. here’s the workaround.

Why batch files can’t be pinned directly

Windows only allows .exe files (executables) to be pinned to the taskbar. Batch files (.bat) are script files that run through cmd.exe. Since the taskbar can’t pin a script directly, you need to create a shortcut that points to cmd.exe with your batch file as an argument.

Method 1: Create a shortcut to cmd.exe running the batch file

  1. Right-click the desktop > New > Shortcut
  2. In the location field, enter:
    cmd.exe /c "C:/path/to/your/batchfile.bat"
    Replace the path with the actual path to your .bat file
  3. Name the shortcut whatever you want
  4. Right-click the new shortcut > Pin to taskbar

The shortcut appears on the taskbar and runs your batch file when clicked.

If you want it to run minimized (no Command Prompt window visible):
Right-click the shortcut > Properties > Shortcut tab > Run: change to “Minimized”

Method 2: Change the shortcut to run with cmd /k (keeps window open)

If you want to see the batch file’s output, use /k instead of /c:
cmd.exe /k "C:/path/to/your/batchfile.bat"

/c runs the command and closes the window. /k runs the command and keeps the window open.

Method 3: Change the shortcut’s icon

The default shortcut icon will be the cmd.exe icon. To change it:

  1. Right-click the shortcut > Properties > Shortcut tab > Change Icon
  2. Browse to an .ico file or another .exe with icons you want to use

Running as administrator

If your batch file requires admin privileges, right-click the shortcut > Properties > Shortcut tab > Advanced > check “Run as administrator.” The shortcut will prompt for UAC elevation when clicked.

The run as administrator shortcut property being needed for system-level batch files is important. Scripts that modify registry values, restart services, or access protected paths need elevation. Setting it at the shortcut level means you don’t have to remember to right-click and run as admin each time.

This approach works for other script types too, not just .bat files. VBScript (.vbs) and PowerShell scripts (.ps1) have the same limitation. For PowerShell: powershell.exe -ExecutionPolicy Bypass -File "C:\path\to/script.ps1" as the shortcut target achieves the same pinnable result.

The /c vs /k distinction is worth knowing. /c is for fire-and-forget batch files where you don’t need to see output. /k is for scripts where you want to read the results. Most utility scripts I pin to the taskbar use /c with minimized window so they run silently in the background.

changing the icon to something other than the cmd.exe default makes the taskbar pin actually usable. cmd.exe’s icon for five different pinned scripts all looks the same. finding a meaningful icon for each shortcut from Windows’ built-in icon library or a custom ico file makes it practical.

Worth noting that the batch file path in the shortcut target needs to be in quotes if it contains spaces. A path like C:\My Scripts/backup.bat without quotes will fail. The format should be: cmd.exe /c "C:\My Scripts/backup.bat" with the path properly quoted.