Prevent Items Pinning to the Taskbar (Explorer Included)

A couple of years ago, I wrote a post about preventing Internet Explorer and Media Player from pinning to the taskbar. It was a fairly simple solution, and the post continues to generate traffic to this site. Unfortunately, though, the methodology died with the Windows 7 era, and none of the advice even applies anymore. I considered updating that post with this new information, but decided this would better serve.

This method is, unfortunately, a bit more intrusive. It does, however, have the advantage of actually working. It will suffice not only for IE and Media Player, but Explorer.exe as well. My old post might work better for you if you’re on an older Windows. Should those steps fail you, though: these will not.

Explanation:

First, some background and a disclaimer. It is somewhat disingenuous to say we will prevent IE and company from pinning. In point of fact, we will simply be removing the icons as they are pinned, such that the user never sees them. I regret that, since 2008R2, I’ve never found a way to truly prevent them from pinning. Since then, I believe it’s been hardcoded into Windows itself, and no amount of registry, file system, or profile manipulation will get around that. I would absolutely love to be proven wrong on this point. In the meantime, though:

If you’ve done any troubleshooting on this front, you may have found that Windows treats taskbar pins somewhat strangely. It stores a .lnk file in the user profile folder, but deleting the file doesn’t remove the icon from the taskbar–it just breaks the shortcut. You may also have found the registry change at HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/Taskband. But of course, clearing that out doesn’t quite work either. And, for some reason, neither does getting rid of them both simultaneously. ¯\_(ツ)_/¯

The Resolution:

This leaves us with one option–verbs. Effectively, these are what you’re seeing whenever you right click an item. VBscript allows us to access these programmatically, and the endgame here is going to be a script at login that waits for the items to appear, then “right-clicks” and chooses to “Unpin from taskbar.” Simple enough, except for explorer.exe, which I’ll touch on afterwards. The script below is simplified (and modified) from the excellent work of the Spiceworks user ryadical, who even includes a function to pin new items as well.

' *** VARIABLE DECLARATION *** 

Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject( "WScript.Shell" )
strAppData = wshShell.ExpandEnvironmentStrings( "%APPDATA%" )
strUserPinned = strAppData & _
	"\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"

' Windows Explorer is called Window Explorer pre-2012, File Explorer after.
If (objFSO.FileExists(strUserPinned & "\Window Explorer.lnk")) Then
	winLNK = strUserPinned & "Window Explorer.lnk"
Else
	winLNK = strUserPinned & "File Explorer.lnk"
End If


' ***UNPIN ITEMS*** 

' Internet Explorer
unpinFromTaskbar strUserPinned, "Internet Explorer.lnk"

' Windows/File Explorer
unpinFromTaskbar strUserPinned, winLNK

' Windows Media Player
unpinFromTaskbar strAllUsersProgramsPath, "Windows Media Player.lnk"


' *** UNPIN FUNCTION ***
Function unpinFromTaskbar (strIconFolder, strIconFile)
        If objFSO.FileExists(strIconFolder & "\" & strIconFile) Then
                Set objFolder = objShell.Namespace(strIconFolder)
                Set objFolderItem = objFolder.ParseName(strIconFile)
                Set colVerbs = objFolderItem.Verbs

                For Each objVerb in colVerbs
			If InStr(Replace(objVerb.name,"&",""),"Unpin") _
			Then objVerb.DoIt
                Next
        End If     
End Function

The script above, if set to run at login, will remove Internet Explorer and Windows Media Player from the taskbar. It will also attempt to remove File Explorer, but depending on your version of Windows, it may fail.


As discussed above, this script will enumerate the actionable “verbs” on a given shortcut; find the one that Unpins it from the taskbar; and invoke it. The problem is that–at least on 2012R2–you may find that right-clicking the explorer icon in your taskbar does not let you unpin it. I have no idea why, but thankfully, the workaround is simple.

If you’re running into that problem, you have one additional step ahead of you. You can manually add the “unpin” verb to the File Explorer shortcut using the following registry tweak in HKEY_CLASSES_ROOT:

HKCR\lnkfile\shellex\ContextMenuHandlers\{90AA3A4E-1CBA-4233-B8BB-535773D48449}
@=”Taskband Pin”

After doing so, you’ll notice the Pin/Unpin option has been restored to the context menu.  With that in place, the script will work the same for File Explorer as it does for any other shortcut.

Top of Page
Go Back



Leave a Reply

Your email address will not be published. Required fields are marked *