Prevent users from pinning a certain application to Taskbar?

Don
Joined
21 Oct 2002
Posts
46,828
Location
Parts Unknown
Windows 7. Roaming Profiles.

Let's say we have programa.exe, it's shortcut looks like this.

Computer A
C:\folder\programa.exe -ID=101

On the next computer it would be..

Computer B
C:\folder\programa.exe -ID=102


If a user pins the shorcut from Comuter A to their Taskbar, when they login to Computer B, they will have ID=101 pinned to their Taskbar.

Can anyone think of a good way to prevent this single application from being pinned (removing the pin on login would be fine)
 
Dealing with pinned stuff at a policy level is a complete nightmare in Windows, why there is nothing in GPO to handle it I will never know. The closest you can get is to have a script run on log in that wipes out the pinned apps and adds back the ones you want to appear there. But that always seemed like a messy bodge to me.
 
Can you not bodge it with an environment variable?

i.e. as an example C:\folder\programa.exe "-ID="%username%

but replace username with a per machine set environment variable.
 
Last edited:
Can you not bodge it with an environment variable?

i.e. as an example C:\folder\programa.exe "-ID="%username%

but replace username with a per machine set environment variable.

These ID's are subject to change every now and then, less of a pain to just edit them manually. Why oh why don't they use ini files
 
The only way is with a vb script. this is the script i use to unpin and pin items on first login for users. ITs dependant on the shortcuts in the start menu, if they do not match up this won't work.

This can be tweaks to work in the start menu as well. Ive got another script for that if you want it.

Option Explicit

Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Const CSIDL_STARTMENU = &HB

Dim objShell, objFSO
Dim objCurrentUserStartFolder
Dim strCurrentUserStartFolderPath
Dim objAllUsersProgramsFolder
Dim strAllUsersProgramsPath
Dim objFolder
Dim objFolderItem
Dim colVerbs
Dim objVerb

Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCurrentUserStartFolder = objShell.NameSpace (CSIDL_STARTMENU)
strCurrentUserStartFolderPath = objCurrentUserStartFolder.Self.Path
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path

' - Remove pinned items - s

'Internet Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs")
Set objFolderItem = objFolder.ParseName("Internet Explorer.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End If

'Windows Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then
Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
Set objFolderItem = objFolder.ParseName("Windows Explorer.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End If

'Windows Media Player
If objFSO.FileExists(strAllUsersProgramsPath & "\Windows Media Player.lnk") Then
Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
Set objFolderItem = objFolder.ParseName("Windows Media Player.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End If

' - Pin to Taskbar -

'Internet Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs")
Set objFolderItem = objFolder.ParseName("Internet Explorer.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If


'Microsoft Outlook 2010
If objFSO.FileExists(strAllUsersProgramsPath & "\Microsoft Office\Microsoft Outlook 2010.lnk") Then
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office")
Set objFolderItem = objFolder.ParseName("Microsoft Outlook 2010.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If

'Microsoft Word 2010
If objFSO.FileExists(strAllUsersProgramsPath & "\Microsoft Office\Microsoft Word 2010.lnk") Then
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Microsoft Office")
Set objFolderItem = objFolder.ParseName("Microsoft Word 2010.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If
 
These ID's are subject to change every now and then, less of a pain to just edit them manually. Why oh why don't they use ini files

Depending on what and how the change is done I'd have thought environment variables would have been a good way to do it - can be deployed at the same time as shortcut afaik and easily changed on the fly.
 
Back
Top Bottom