Advertisement
Guest User

Toggle Pinned State of App on Taskbar

a guest
Nov 30th, 2011
1,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # based on: http://techibee.com/powershell/pin-applications-to-task-bar-using-powershell/685
  2. function toggle-pin
  3. {
  4.   param([parameter(Mandatory = $true)]
  5.         [string]$application)
  6.  
  7.   $al = $application.Length
  8.   $appfolderpath = $application.SubString(0, $al - ($application.Split(“\”)[$application.Split("\").Count - 1].Length))
  9.  
  10.   $objshell = New-Object -ComObject “Shell.Application”
  11.   $objfolder = $objshell.Namespace($appfolderpath)
  12.   $appname = $objfolder.ParseName($application.SubString($al - ($application.Split(“\”)[$application.Split("\").Count - 1].Length)))
  13.   $verbs = $appname.verbs()
  14.  
  15.   foreach ($verb in $verbs)
  16.   {
  17.     if ($verb.name -match(&K))
  18.     {
  19.       $verb.DoIt()
  20.     }
  21.   }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement