vrijdag 4 november 2011

Pin Items to the Start Menu

If you wanna Pin a shortcut to the Start Menu, you can do this by rightclicking on the shurtcut and clicking on the "Pin to Start Menu". This doesn't work when your Windows Vista/XP/7 is NOT in Classic Mode.

If you want to do this via a script you can use the following vb-scripts:

Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Set objShell = CreateObject("Shell.Application")
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Accessories")
Set objFolderItem = objFolder.ParseName("Calculator.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

If you are using a Windows with a language pack, you don't have to change "\Accessories" (line 6), line 7 shows the link you want to pin (again keep this the original Englishname when using an Englisch Windows with a language pack).
In line 10, you have to change "Pin to Start Menu" to the Windows language or when using a language pack, the language of the pack.
Dutch: "Aan het menu Start vastmaken"

Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Set objShell = CreateObject("Shell.Application")
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Accessories")
Set objFolderItem = objFolder.ParseName("Calculator.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
Wscript.Echo objVerb
Next

You can use the above (second) vb-script to see which rightmouse-clicks are available for the shortcut calculator. Please ommit the "&".