The corporate image being used on my laptop keeps forcing File Explorer to be pinned to my taskbar. I have gone round and round with them about this problem (and others I have had) but am giving up on that front since the other problems are fixed. What I want to try to accomplish as a work around is to create a script that I can run when I log in that will unpin File Explorer from the taskbar for me. I have been all over the internet with various powershell, vbscript and batch files. Most of the scripts work great for any thing pinned to the taskbar EXCEPT File Explorer. Most pinned items are in %AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar and I can see File Explorer there. However all the scripts I see use the verbs of the object and look for an unpin from taskbar command and run it. File Explorer does not have that. I have searched my entire hard drive and cannot file a file with the unpin command for file explorer. If I delete the file and remove the taskband registr in HKCU the item is not longer pinned, but still shows on the taskbar. If I click it, it will crash and the remove itself. If I refresh explorer.exe, the item is pinned to the taskbar again. Any ideas on how to do this?
1 Answer
It should still work with the method used by PinTo10 which is based on this kinda crazy method where you basically rename your own executable to explorer.exe to get the privileges windows has for pinning.
It also seems you have to use a special link and not the normal one but in my tests if you use the one from "C:\ProgramData\Microsoft\Windows\Start Menu Places" it still works.
So that would be:
PinTo10v2.exe /unpintb "C:\ProgramData\Microsoft\Windows\Start Menu Places\01 - File Explorer.lnk"
If you prefer a purely scripted method (should be enough for unpinning just not for pinning) this would be something like
Set wso = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set sho = CreateObject("Shell.Application")
sourcedir = fso.GetFile(WScript.ScriptFullName).ParentFolder
Set folder = sho.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu Places")
For Each item In folder.Items
If contains(item.Name,"Explorer") Then
item.InvokeVerb("taskbarunpin")
End If
Next
' Funktion um zu prüfen ob ein string einen anderen enthält
Function contains(sourceStr, checkStr)
contains=InStr(1, sourceStr, checkStr, vbTextCompare) > 0
End Function
(I could not test it with the newest Win 10 builds but so far they did never touch this part since they made it completely intransparent with windows 10)
-
Amazing! I finally had time to test and got this to work. My missing piece was the file location in Start Menu Places. Since it shows there as a folder and not an exe, I did not see that in all my searches. Thanks for taking the time to help!– LtlBearCommented Jan 24, 2018 at 18:54
-
1Great you got it to work! I know exactly how annoying it is that MS does not provide a proper way to unpin programmatically. I'm not even sure whether I should be mad that this stuff is so half assed or happy because at least there is atm a way for every program to unpin it even if many need special cases even if only because this is all such a mess. If you found my answer helpful feel free to mark it as accepted. Commented Jan 25, 2018 at 10:07
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer "NoPinningToTaskbar"=dword:00000001