Alex Rivera | Logout

How to pin to taskbar using PowerShell

Asked 2012-03-16T15:09:20.280
23

How can I pin some programs to taskbar on Windows 7 using PowerShell? Please explain step-by-step.

And How to modify the following code to pin a folder to taskbar? For Example

$folder = $shell.Namespace('D:\Work') 

In this path, example named folder.

Edit
Report

1 Answer

24

You can invoke a Verb (Pin to Taskbar) using the Shell.Application COM object. Here's some example code:

http://gallery.technet.microsoft.com/scriptcenter/b66434f1-4b3f-4a94-8dc3-e406eb30b750

The example is somewhat complicated. Here is a simplified version:

$shell = new-object -com "Shell.Application"  
$folder = $shell.Namespace('C:\Windows')    
$item = $folder.Parsename('notepad.exe')
$verb = $item.Verbs() | ? {$_.Name -eq 'Pin to Tas&kbar'}
if ($verb) {$verb.DoIt()}
answered 2012-03-16T15:13:44.920

Your Answer