Pin Icons to Start Menu for All Users with GPO

1 Shares

Pinning and unpinning icons to the Start Menu or Taskbar can be a pain on Windows 2008 or Windows 7. After doing some research I came up with an how to that I wanted to share with you today.

The first problem I got was that the Pin to Taskbar / Start Menu was missing from the menu.

It seems like it’s not possible to do this when the Start Menu are redirected to a network drive. Simply copy the icons you want to your Desktop.

Pin the icons to the locations you want so the settings get’s saved to registry.

Now head into the %AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned folder and copy the icons to a network share you can use in Group Policy Preferences.

Define the folders you want to copy

Pinning icons to the users Start menu contains of 2 components, the icons in the User Pinned folder and in registry. Open registry and export HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage2

I’m using the fantastic tool Reg2XML to convert registry files to XML.

The last step is to import the XML file to Group Policy Preferences.

Thanks Microsoft for making this so easy! There’s also a custom PowerShell module you can use to pin / unpin icons, but this didn’t support command line switches. What I mean with this is that I couldn’t add icons for applications like Notes where you have Notes.exe =H:\Notes\Data\Notes.ini in the path.

Are you doing this in other ways? Please share with the Citrix Community by leaving a comment below.

1 Shares

Automation Framework Community Edition

The fastest way to build your lab environment.

Virtual Expo

Friday 30th of September 2022

26 thoughts on “Pin Icons to Start Menu for All Users with GPO”

  1. I have used this script to remove all default shortcuts and add Internet Explorer + Word and Excel
    You can edit it to add more shotcuts.

    *******************************
    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    ‘ CONSTS
    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    Const HKEY_CLASSES_ROOT = &H80000000
    Const HKEY_CURRENT_USER = &H80000001
    Const HKEY_LOCAL_MACHINE = &H80000002
    Const HKEY_USERS = &H80000003
    Const HKEY_CURRENT_CONFIG = &H80000005

    Const CSIDL_COMMON_PROGRAMS = &H17
    Const CSIDL_PROGRAMS = &H2

    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    ‘ OBJECTS
    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    Set objRegistry = GetObject(“winmgmts:\\.\root\default:StdRegProv”)
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objApplication = CreateObject(“Shell.Application”)
    Set objAllUsersPrograms = objApplication.NameSpace(CSIDL_COMMON_PROGRAMS)
    Set objUserPrograms = objApplication.NameSpace(CSIDL_PROGRAMS)

    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    ‘ VARIABLES
    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    Dim arrSubValues, arrDeleteApps, arrPinApps, strAllUsersProgramsPath

    strAllUsersProgramsPath = objAllUsersPrograms.Self.Path & “\”
    strUserProgramsPath = objUserPrograms.Self.Path & “\”
    arrDeleteApps = Array(“displayswitch.lnk”, “remote desktop connection.lnk”, “sticky notes.lnk”, “snipping tool.lnk”, “calculator.lnk”, “paint.lnk”, “xps viewer.lnk”, “windows fax and scan.lnk”, “Magnify.lnk”)

    Call Main

    Sub Main()
    DeleteStartMenuApps HKEY_CURRENT_USER, “”, arrDeleteApps

    DoVerb “Pin to Start Menu”, strUserProgramsPath & “Internet Explorer.lnk”

    ‘Get the version of Office installed, so that we can pin it to the start menu
    If IsProgramInstalled(objRegistry, “Microsoft Office Enterprise 2007”) = TRUE Then
    DoVerb “Pin to Start Menu”, strAllUsersProgramsPath & “Microsoft Office\Microsoft Office Word 2007.lnk”
    DoVerb “Pin to Start Menu”, strAllUsersProgramsPath & “Microsoft Office\Microsoft Office Excel 2007.lnk”
    Else
    DoVerb “Pin to Start Menu”, strAllUsersProgramsPath & “Microsoft Office\Microsoft Word 2010.lnk”
    DoVerb “Pin to Start Menu”, strAllUsersProgramsPath & “Microsoft Office\Microsoft Excel 2010.lnk”
    End If
    End Sub

    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    ‘ FUNCTIONS AND SUBS
    ‘=-=-=-=-=-=-=-=-=-=-=-=-=
    Function DoVerb(strVerb, strPath)
    On Error Resume Next
    strFolder = objFSO.GetParentFolderName(strPath)
    strFile = objFSO.GetFileName(strPath)

    Set objFolder = objApplication.NameSpace(strFolder)
    Set objFolderItem = objFolder.ParseName(strFile)

    For Each ItemVerb In objFolderItem.Verbs
    If StrComp(Replace(ItemVerb.Name, “&”, “”), strVerb, vbTextCompare) = 0 Then
    ItemVerb.DoIt
    Exit Function
    End If
    Next
    On Error Goto 0
    End Function

    Sub DeleteStartMenuApps(hDefKey, sSubKeyUser, arrDeleteApps)
    If Len(sSubKeyUser) > 0 Then
    sSubKeyName = sSubKeyUser & “\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist”
    Else
    sSubKeyName = “Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist”
    End If

    objRegistry.EnumKey hDefKey, sSubKeyName, arrSubKeys

    If IsArray(arrSubKeys) Then
    For i = 0 to UBound(arrSubKeys)
    sTempSubKeyName = sSubKeyName & “\” & arrSubKeys(i) & “\Count”
    objRegistry.EnumValues hDefKey, sTempSubKeyName, arrSubValues

    If IsArray(arrSubValues) Then
    For m = 0 to UBound(arrSubValues)
    For n = 0 to UBound(arrDeleteApps)
    If InStr(UCase(RunROT13(arrSubValues(m))), UCase(arrDeleteApps(n))) > 0 Then
    objRegistry.DeleteValue hDefKey, sTempSubKeyName, arrSubValues(m)
    End If
    Next
    Next
    End If
    Next
    End If
    End Sub

    Function RunROT13(strInput)
    For i = 1 to Len(strInput)
    iChr = Asc(Mid(strInput, i, 1))
    If (iChr >= 65 and iChr = 97 and iChr = 78 and iChr = 110 and iChr <= 122) Then
    strOutput = strOutput & Chr(iChr -13)
    Else
    strOutput = strOutput & Chr(iChr)
    End If
    Next

    RunROT13 = strOutput
    End Function

    Function IsProgramInstalled(objRegistry, strProgramDisplayName)
    intRegistryHive = HKEY_LOCAL_MACHINE
    strRegistryKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

    objRegistry.EnumKey intRegistryHive, strRegistryKey, arrSubkeys

    IsProgramInstalled = FALSE

    For Each strSubkey In arrSubkeys
    strDisplayName = ReadRegistryValue(objRegistry, "STRING", intRegistryHive, strRegistryKey & "\" & strSubkey, "DisplayName")

    If UCase(strDisplayName) = UCase(strProgramDisplayName) Then
    IsProgramInstalled = TRUE
    Exit For
    End If
    Next
    End Function

    Function ReadRegistryValue(objRegistry, strType, intRegistryHive, strSubKeyName, sValueName)
    Select Case UCase(strType)
    Case "DWORD"
    objRegistry.GetDWORDValue intRegistryHive, strSubKeyName, sValueName, strValue
    Case "EXPANDEDSTRING"
    objRegistry.GetExpandedStringValue intRegistryHive, strSubKeyName, sValueName, strValue
    Case "MULTISTRING"
    objRegistry.GetMultiStringValue intRegistryHive, strSubKeyName, sValueName, strValue
    Case "STRING"
    objRegistry.GetStringValue intRegistryHive, strSubKeyName, sValueName, strValue
    End Select

    ReadRegistryValue = strValue
    End Function

    Reply
  2. Hi
    I find redirected Startmenu convenient for smaller Sites (up to 200 Users).
    I share the folder on the network, enable ABE on that one, create a GPO for redirecting the Startmenu (Startmenu has to be classic style) for all users and give permissions to APP Groups, where I add the according Users to. The Icons have to be created from one of the XenApp Servers. Any user without being member in that group does not see the Icon, only members do.
    I don’t like that folder sitting on a DFSR

    Reply
  3. Thanks for the article which will come in handy for our XenApp 65 project. Is there a similar script for my existing Windows 2003 servers?

    Reply
  4. Actually it’s very simple, you just have to follow the Windows way. I can see already from the screen shots the issue…

    I will post something about it on my website

    Thomas

    Reply
    • Thomas,

      Your blog was nice, but unfortunately, your method does not work for Citrix published apps, which is the point of this entire thread.

      Regards,

      Reply
  5. I’ve tried it with different OS (Win7 x32, Win7 x64), but it didn’t work for me.

    cscript C:\tmp\PinItem.vbs /item:”c:\windows\system32\mspaint.exe”

    Script tells me “Item pinned: True” but I can’t find the Item in the start menu

    Did I anything wrong?

    Thanks in advance,
    Rainer

    Reply
  6. Great article! What about Windows Server 2012 r2? The start menu redirection works well but it seems not compatible with the Citrix receiver 4.2 and the creation of shortcuts.

    Any work around?

    Thanks!

    Reply
  7. I’m new to scripting. Where would you put the script that Dagfinn has as the begging of this post.

    Reply
  8. Hi Guys,

    Thank you so much as I had hard times locating for a solution. The script and batch worked wonderfully on Windows 8 in this instance.

    Guys, you real did a wonderful job and please keep it up.

    Regards
    Kenneth
    From Singapore

    Reply

Leave a Comment