The Crayon Community!

Welcome to The Crayon Community! Sign in | Join | Help
in Search

Ragnar Harper`s blog on Microsoft technology and security

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

Published Apr 17 2009, 11:02 PM by ragnar
Filed under: ,

Comments

 

Om Windows 7 og annen teknisk moro said:

Fra Start-meny eller andre steder kan jeg høyre klikke på et ikon og velge “Pin to Start menu” eller

April 18, 2009 1:38 PM
 

Om Windows 7 og annen teknisk moro said:

Skrev for en kort stund siden om automatisering av Pin to Start menu og Pin to taskbar . Og da spesielt

April 24, 2009 8:11 AM
 

Ali said:

How you can run this sript in the windows kindly kind me

It shows the error like invalid charaters

Thanks in Advance

June 29, 2009 1:38 PM
 

Jan Egil`s blog on Microsoft Infrastructure said:

I`ve created a PowerShell module for working with pinned applications in Windows 7 and Windows Server

February 26, 2010 4:44 PM
 

Pin and unpin applications from the taskbar and Start-menu using Windows PowerShell « Jan Egil`s Admin-Blog said:

Pingback from  Pin and unpin applications from the taskbar and Start-menu using Windows PowerShell «  Jan Egil`s Admin-Blog

February 26, 2010 4:55 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

About ragnar

Technology geek and Microsoft MVP.
Powered by Community Server (Commercial Edition), by Telligent Systems