Cleaning-up Windows explorer.exe Quick Access default entries

I needed to do multiple hours research how to get Windows File Explorer (explorer.exe) Quick Access list cleaned out, since I did not want to remove it completely, but since the server was a Session Host for multiple users, I did not wanted to have libraries like Desktop, Documents, Pictures or Downloads visible.

I already earlier figured out how to remove those libraries under “This PC”, which was easy by just editing the registry with GPO and changing one key value for each entry as “Hide” instead of default “Show” like “Help Desk Survival” blog suggested:

You can hide the libraries folders from file explorer by changing the following registry

Pictures: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag

Videos: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag

Downloads: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag

Music: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag

Desktop:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag

Documents: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag

For each of these paths you have to change the value of the key ThisPCPolicy to “Hide”

https://helpdesksurvival.wordpress.com/2018/04/19/gpo-hide-libraries-folders-from-file-explorer/

I also had “3D Objects” library under “This PC”, so needed to find out it as well from the registry… It did not had PropertyBag branch by default, but the same “ThisPCPolicy” key like above worked for that as well with “Hide” as its value:

SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag

I truly recommend doing this type of changes as gently as possible, since there can be issues at future Windows versions othervise… Quite many blogs and articles are for example are recommending to delete the registry entries for libraries to get them removed under “This PC”, but based on my experience such things may lead problems at the future. Therefore I opted to use softer methods like properly hiding libraries under “This PC” and cleaning up Quick Access list instead of deleting, which additionally leaves the functionality available for more advanced users to use it if they like.

Cleaning the Quick Access

So how to get the Quick Access cleaned from default entries? The best post I was able find was this from “crypticus” at NTLite’s community, which actually explains how to add and remove entries: https://www.ntlite.com/community/index.php?threads/solved-automaticdestinations-edits-for-quick-access.2691/post-24032

It gave a good idea how to do the clean-up with PowerShell, which is easy to build into login script or to use as login time scheduled task which I prefer much more than login scripts. Here is an example how above post recommended to remove Pictures library:

$p=$env:USERPROFILE + '\Pictures'; $o = New-Object -Com shell.application; ($o.Namespace('shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}').Items() | Where-Object { $_.Path -like $p }).InvokeVerb('unpinfromhome')

If you want to get an idea how this works, I recommend trying these command first, which should give you a list of all the items under the Quick Access:

$o = New-Object -Com shell.application
$o.Namespace('shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}').Items()

But since I had quite specific use case that I wanted to delete all the default entries I started to combine those as “one liner”:

$o = New-Object -Com shell.application; ($o.Namespace("shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}").Items() | Where-Object { ($_.Path -like $env:USERPROFILE + "\Pictures") -or ($_.Path -like $env:USERPROFILE + "\Desktop") -or ($_.Path -like $env:USERPROFILE + "\Downloads") -or ($_.Path -like $env:USERPROFILE + "\Documents") }).InvokeVerb("unpinfromhome")

Above worked just nicely if you ran it only once, or if there were at least one of the specified libraries pinned. Othervise it produced an error about calling a method on null-valued expression… Also the command itself was quite nasty looking, so I needed to improve it. At this point I took the lazy route and gave the above to ChatGPT (3.5) and asked it to mitigate the possible error and when it did that, I continued and asked it to improve the readability of the code. Here is the outcome of that:

$o = New-Object -ComObject shell.application; ($o.Namespace("shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}").Items() | Where-Object { "$env:USERPROFILE\Pictures", "$env:USERPROFILE\Desktop", "$env:USERPROFILE\Downloads", "$env:USERPROFILE\Documents" -contains $_.Path }) | ForEach-Object { $_.InvokeVerb('unpinfromhome') }

This looked really satisfying for my needs, and did not produced any errors, no matter how many times you run it and what entries there were in Quick Access. For some reason my Windows box also had default user desktop pinned, that could be because of my earlier tests or something, but I decided to add C:\Users\Default\Desktop to be cleaned away from Quick Access as well even it should not be there at first place:

$o = New-Object -ComObject shell.application; ($o.Namespace("shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}").Items() | Where-Object { "$env:USERPROFILE\Pictures", "$env:USERPROFILE\Desktop", 'C:\Users\Default\Desktop', "$env:USERPROFILE\Downloads", "$env:USERPROFILE\Documents" -contains $_.Path }) | ForEach-Object { $_.InvokeVerb('unpinfromhome') }

So now I had the clean-up “script” ready and the next thing I needed to do was to automate it for of the all users. Like I wrote earlier, that I don’t like login scripts, I used GPO to create a scheduled task under user context that does have user logon as its trigger:

Since I did not wanted to have any actual script file to be run, I embedded the whole thing inside “-command” parameter of PowerShell. To do that I needed to escape the double quotes, so here is the whole arguments row content:

-noprofile -executionpolicy bypass -command "$o = New-Object -ComObject shell.application; ($o.Namespace(\"shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}\").Items() | Where-Object { \"$env:USERPROFILE\Pictures\", \"$env:USERPROFILE\Desktop\", 'C:\Users\Default\Desktop', \"$env:USERPROFILE\Downloads\", \"$env:USERPROFILE\Documents\" -contains $_.Path }) | ForEach-Object { $_.InvokeVerb('unpinfromhome') }"

Hopefully this eases up your work, since it took too many hours for me to figure everything out. 🙂