Pin applications to Windows 7 Taskbar
Lately I seen some posts on the net about how to pin applications to the taskbar in Windows 7. As there is no direct API to do this, you could use the Shell Objects, well known from VBScript. As for me, I like to use Powershell (no surprise) and I created a Powershell script that could pin applications to the Windows 7 taskbar using the Shell Objects.
# ==============================================================================================
#
#
# NAME: Add-ToTaskbar.ps1
#
# AUTHOR: Ragnar Harper , Crayon
# DATE : 17.04.2009
#
# COMMENT: This version only supports English locale. You need to change $PinVerb to support
# other locale.
#
# http://blog.crayon.no/blogs/ragnar
# ==============================================================================================
$PinVerb="Pin to Taskbar"
if($args.count -ne 1)
{
Write-Host "Wrong number of arguments."
Write-Host "usage: Add-ToTaskbar.ps1 [program to pin]"
Write-Host "example: Add-ToTaskBar.ps1 c:\windows\system32\calc.exe"
Write-Host "You must include folderpath to program"
}
else
{
$file=$args[0]
$path=$file.SubString(0,$file.Length-($file.Split("\")[$file.Split("\").Count-1].Length))
$shell=new-object -com "Shell.Application"
$folder=$shell.Namespace($path)
$item=$folder.ParseName($file.SubString($file.Length-($file.Split("\")[$file.Split("\").Count-1].Length)))
$verbs=$item.Verbs()
foreach($v in $verbs){if($v.Name.Replace("&","") -match $PinVerb){$v.DoIt()}}
}
You could also download the script from http://blog.crayon.no/files/folders/scripts/entry12955.aspx