Jump to content

Script to pin/unpin items to/from Start Menu in Win7/2k8r2?


Recommended Posts

Posted

Hi everyone, hoping there's someone who could help me out.

 

Trying SO hard to get this to work, but it's a little bit beyond me.

 

Given that there's no policy to set the pinned start menu icons for windows 7 in gp (oh *deity* why not??!?!?!) I started looking for scripts as Angry Technician suggested.

 

Found a cracking one I thought I'd modify:

 

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

 

...And success! I've now got a calculator shortcut where I want it! But, when I change it to the following (to try and get paint in there) it doesn't work:

 

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("Paint.lnk")

Set colVerbs = objFolderItem.Verbs

For Each objVerb in colVerbs

If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt

Next

 

Is there any way to change this script so I can put any shortcut in there? Can I also put in shortcuts that aren't in accessories? I'm no whiz with scripts so please be kind!

 

Thanks folks. :)

Posted

Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)

strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path

This section says use the All Users Start menu.

 

Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Accessories")

And within that the Accessories folder, so for a folder in All Users start menu called bob, you'd want

 

Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\bob")

 

And for something in the top level of the start menu, just

 

Set objFolder = objShell.Namespace(strAllUsersProgramsPath)

 

To check you have the shortcut in the All Users right click on All Programs and choose Open All Users, some shortcuts might be default user ones copied to each user's profile, but Paint doesn't seem to be one of them, odd

Posted

I just copied the bottom script (for paint) into notepad, saved as a .vbs and ran it. I now have Paint pinned to my Start Menu (Thanks for that :p ), so I have no idea why you cannot get it working.

 

Did you try it on its own, or just as an extension of the script that adds Calculator?

Posted

:(

 

...It's because I was copying the

 

Const CSIDL_COMMON_PROGRAMS = &H17

Const CSIDL_PROGRAMS = &H2

 

bit as well. It works fine if I don't do that.

 

Bleergh. :rolleyes:

Posted

Ah, you were doing them all in 1 script then?

 

You'd only need, for the 2nd/3rd/etc times to have

 

Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Accessories")

Set objFolderItem = objFolder.ParseName("Paint.lnk")

Set colVerbs = objFolderItem.Verbs

For Each objVerb in colVerbs

If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt

Next

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...