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.
First, launch the program as you normally would. At the bottom of your screen, the program icon appears on the taskbar. Right-click it and, from the menu, select Pin to taskbar. The icon is pinned permanently to the taskbar.
There is no option to pin the Power setting to taskbar, but as a workaround you may create a shortcut for 'Shutdown' and 'Restart' and pin the shortcut to taskbar.
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()}
Another way
$sa = new-object -c shell.application
$pn = $sa.namespace($env:windir).parsename('notepad.exe')
$pn.invokeverb('taskbarpin')
Or unpin
$pn.invokeverb('taskbarunpin')
Note: notepad.exe may not be under %windir%
, it may exist under %windir%\system32
for server OS's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With