Unpin File Explorer from the taskbar in Windows 10 via script or batch file

1

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?

LtlBear

Posted 2018-01-09T18:26:05.167

Reputation: 61

Not sure if this works but what if you get the TaskBar to your liking, then create the registry value: HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer "NoPinningToTaskbar"=dword:00000001 – HelpingHand – 2018-01-09T20:27:39.690

Thanks for the idea, but unfortunately that did not work. I had to reboot to get the registry setting to implement. Upon reboot the File Explorer was back in the taskbar but now I could not unpin it manually. – LtlBear – 2018-01-10T20:19:46.053

You only need to kill and relaunch explorer.exe for it to take effect but maybe policy trumps it. – HelpingHand – 2018-01-10T20:57:45.857

1I did not think about killing explorer to make it take effect. However, killing explorer and restarting explorer pins it back to the taskbar. I don't think this is a policy thing. There are plenty of posts on the internet with people having this same problem. A good chunk of them cannot get it fixed without running a repair in Windows. Unfortunately that is not an option for me and to re-install I have to have the corporate image which has the problem built in. – LtlBear – 2018-01-11T18:45:13.430

Answers

1

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)

Syberdoor

Posted 2018-01-09T18:26:05.167

Reputation: 1 364

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! – LtlBear – 2018-01-24T18:54:20.337

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. – Syberdoor – 2018-01-25T10:07:56.397