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

Filed under: ,

Comments

# Pin and unpin applications from the taskbar and Start Menu « windows by wredSYS said:

Pingback from  Pin and unpin applications from the taskbar and Start Menu « windows by wredSYS

Tuesday, March 01, 2011 8:46 PM
# ?????? ?????????????????? ???????????? ?????????? Windows 2008 R2 ???????????????? | Axl Blog said:

Pingback from  ?????? ?????????????????? ???????????? ?????????? Windows 2008 R2 ???????????????? | Axl Blog

Wednesday, November 16, 2011 11:31 AM