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

Solution 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)