≡ Menu

Pin applications to Task bar using powershell

Description:

This powershell function helps you pinning the specified program to Task bar in windows 7/Windows Vista/Windows 2008 computers.

Usage:

[PS]:>Pinto-Taskbar -application “c:windowssystem32calc.exe”

The above statement Pins the calculator program to Task bar.

Code:

function pinto-taskbar {

param(

[parameter(Mandatory = $true)]

[string]$application

)

$appfolderpath = $application.SubString(0,$application.Length-($application.Split(“”)[$application.Split(“”).Count-1].Length))

$objshell = New-Object -ComObject “Shell.Application”

$objfolder = $objshell.Namespace($appfolderpath)

$appname = $objfolder.ParseName($application.SubString($application.Length-($application.Split(“”)[$application.Split(“”).Count-1].Length)))

$verbs = $appname.verbs()

foreach ($verb in $verbs) {

if($verb.name.replace(“&”,””) -match “Pin to Taskbar”) {

$verb.DoIt()

}

}

}

{ 1 comment… add one }
  • PowerShell November 30, 2011, 12:33 pm

    Backslashes missing? May not work in non-English envs?

    Here’s a modified version that toggles the pin state — perhaps it even works for a variety of different locales…

    http://pastebin.com/bt1iqBHY

Leave a Comment