Script to pin item to taskbar (or Start menu) in Windows 7

By aaron.axvig, Thu, 02/19/2009 - 03:00

After pounding my head at this off-and-on over the last five weeks (previously thwarted), I have mashed enough VBScript skills into it (my head) that I figured out how to script the pinning of items to the taskbar.

 

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\")
Set objApp = objFolder.ParseName("Notepad.lnk")
For Each verb in objApp.Verbs()
If verb.Name = "Pin to Tas&kbar" Then verb.DoIt
Next

For this to work, you need to have a valid shortcut Notepad.lnk in C:\.  To do a pin to the start menu, replace “Pin to Tas&kbar” with “Pin to Start Men&u”.  Yes, you need the ampersands, they are there as keyboard shortcuts.  Right-click on a shortcut and push K and it will pin that to the taskbar.

Tags