There is no easy way to Pin items to the Start Menu or on the Taskbar, it is by design to prevent programs filling up these locations ( http://technet.microsoft.com/en-us/magazine/2006.01.windowsconfidential.aspx ). However it is possible to script the pinned items.
When you rightclick on an object (shortcut / file) in explorer, you are presented with a context menu. These actions are known as “Shortcut Menu items” or “Verbs” in shell terms. These verbs can be enumerated and executed programmatically.
Example to get all verbs on the Internet Explorer link:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Const CSIDL_STARTMENU = &HB Set objShell = CreateObject("Shell.Application") Set objUserFolder = objShell.NameSpace (CSIDL_STARTMENU) strUserFolderPath = objUserFolder.Self.Path Set objFolderIE = objShell.Namespace(strUserFolderPath & "\Programs") Set objFolderItemIE = objFolderIE.ParseName("Internet Explorer.lnk") Set colVerbs = objFolderItemIE.Verbs For Each objVerb in colVerbs Wscript.Echo objVerb Next |
Result from the example above:
When scripting, you basically point out the object , and apply an action(verb):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Const CSIDL_COMMON_PROGRAMS = &H17 Const CSIDL_PROGRAMS = &H2 Const CSIDL_STARTMENU = &HB Dim objShell Dim objAllUsersProgramsFolder Dim strAllUsersProgramsPath Dim objUserFolder Dim strUserFolderPath Dim objFolderIE Dim objFolderItemIE Dim colVerbs Dim objVerb Set objShell = CreateObject("Shell.Application") Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS) strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path Set objUserFolder = objShell.NameSpace (CSIDL_STARTMENU) strUserFolderPath = objUserFolder.Self.Path ' Internet Explorer. Select shortcut to apply the action on Set objFolderIE = objShell.Namespace(strUserFolderPath & "\Programs") Set objFolderItemIE = objFolderIE.ParseName("Internet Explorer.lnk") Set colVerbs = objFolderItemIE.Verbs ' Choose your verb For Each objVerb in colVerbs ' If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt ' If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt ' If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt ' If Replace(objVerb.name, "&", "") = "Unpin from Start Menu" Then objVerb.DoIt ' If Replace(objVerb.name, "&", "") = "Fäst i Aktivitetsfältet" Then objVerb.DoIt ' If Replace(objVerb.name, "&", "") = "Fäst på Start-menyn" Then objVerb.DoIt ' If Replace(objVerb.name, "&", "") = "Ta bort från Aktivitetsfältet" Then objVerb.DoIt ' If Replace(objVerb.name, "&", "") = "Ta bort från Start-menyn" Then objVerb.DoIt Next ' Done |