+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Script to pin/unpin items to/from Start Menu in Win7/2k8r2? in Coding and Web Development; Hi everyone, hoping there's someone who could help me out. Trying SO hard to get this to work, but it's ...
  1. #1

    Miscbrah's Avatar
    Join Date
    Dec 2011
    Posts
    933
    Thank Post
    260
    Thanked 265 Times in 163 Posts
    Rep Power
    116

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

    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.

  2. #2

    Join Date
    Jan 2007
    Location
    Nottinghamshire
    Posts
    530
    Thank Post
    1
    Thanked 84 Times in 58 Posts
    Rep Power
    38
    Quote Originally Posted by Miscbrah View Post
    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

  3. #3

    Join Date
    Feb 2009
    Posts
    9
    Thank Post
    0
    Thanked 3 Times in 2 Posts
    Rep Power
    0
    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?

  4. #4

    Join Date
    Jan 2007
    Location
    Nottinghamshire
    Posts
    530
    Thank Post
    1
    Thanked 84 Times in 58 Posts
    Rep Power
    38
    Both worked for me too

  5. #5

    Miscbrah's Avatar
    Join Date
    Dec 2011
    Posts
    933
    Thank Post
    260
    Thanked 265 Times in 163 Posts
    Rep Power
    116

    Red face



    ...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.

  6. #6

    Join Date
    Jan 2007
    Location
    Nottinghamshire
    Posts
    530
    Thank Post
    1
    Thanked 84 Times in 58 Posts
    Rep Power
    38
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 13
    Last Post: 17th October 2011, 10:02 AM
  2. Replies: 3
    Last Post: 18th May 2011, 02:11 PM
  3. Removed Control Panel from Start Menu
    By Mr.Ben in forum Windows
    Replies: 5
    Last Post: 11th April 2011, 02:47 PM
  4. Hide Startup Folder from Start Menu
    By FN-GM in forum Windows
    Replies: 7
    Last Post: 30th March 2011, 11:06 PM
  5. Add favourites to the start menu
    By FN-GM in forum How do you do....it?
    Replies: 11
    Last Post: 21st June 2008, 12:03 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •