Windows – How to force custom default Sort By options for all folder types in Windows Explorer

windowswindows 10windows 7windows 8windows-explorer

Quick note to eager mods: this is not a duplicate 🙂

My question has 3 parts, but to make it easy, of course I will mark as answered any answer that only addresses the 3rd part:

  1. I wish to understand how Windows Explorer works in the sense of why this happens. I know folders can be of different types (general, music library, photo gallery etc) and that windows automatically decides which is which continuously based on what's in a folder. There's also different (types of) drives in a system, external drives, music player drives, phone drives whatever. All of these in addition to it being a folder by folder setting, contribute to the problem but I can't piece together how come the Sort By items lists get reset.

    • For instance: I go to D:\Downloads\ in Explorer and go to Sort By and go to More and scroll all the way down to Date Modified, and click okay, then go to Sort By again and select Date Modified. Cool. Now, I go in my browser and save a file, browser asks where to save, I browse to D:\Downloads\ GUESS WHAT? DATE MODIFIED ISN'T THERE. Ok, I set it again there as well. I open another program with another windows shell browse menu, date modified isn't there either. I set all of them, reboot and/or install a totally useful windows update, it gets reset again.
    • ^ Why is it not even actually per folder but per shell, and why does the Sort By list get reset? Where is this setting stored?
  2. I normally would have asked what most seemingly related questions on this topic on SU ask (like this, and this):

    • How to change my Sort By options and then apply them to all folders. – Bad question to ask and answer, because it will get reset, or will not really be applied to all types of folders and all future drives and connected devices.
    • How to force all the folders on my system to be a "general items" folder so that then I can change the Sort By options for all my general items folders. – Also a bad question because a. I want to have different types of folders not just general items folders, and b. it as sure as anything in the universe, will eventually get reset by MS whether on purpose, or design stupidity.
  3. If you've made it this far and with this knowledge think you have an elegant permanent answer please help us, maybe just answer this 10y/o question. But, I'm gonna ask a different question:

    • Is there any sort of developer way to access, or an existing shell extension hack, or background process, or something, I don't care how invasive, that we can leverage, to continuously overwrite the Windows Explorer Sort By list with the actual Sort By criteria of –OUR– choosing? Thank you very much.
    • Clarification: My goal simple: for any and all windows explorer windows where there is an option to right click and go to Sort By menu, to be able to find Date Modified in there (and other custom options of my choosing, size, date taken etc). Then if I choose to Sort By Date Modified, I want that change to be remembered forever until I change it again. I would be OK with a solution where if I choose Date Modified in one folder, for all other types of folders everywhere else to also change to Date Modified globally. Seems like more sustainable than per-folder settigns.

In the last years, Windows As A Service releases have brought huge overhauls and investments, questionable at best (e.g. making windows drivers hostage to the invasive app store nobody wants), and yet everyday-things like this problem or the max file path length, have remained unaddressed or unanswered for decades. Makes you question whether anyone working at MS uses their own product non-superficially. No, but I'm sure they care, I guess they gosh just still don't have enough telemetry to know that this totally-in-your-face basic QA problem is a problem…

Best Answer

I've been working on a comprehensive explanation of folder views here. Take a look at that for starters.

You first question has me wondering if you've "maxed out" on saved views. What value is returned by this PowerShell code?

((gp "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU").Nodeslots).count

And what is you ultimate, specific goal??? I've found a couple of ways to custiomzie view defaults.

Apply to Folders is the easiest way to customize view defaults. To check which FolderTypes have a custom default set, run this PowerShell:

(Get-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults').Property |
   %{(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\$_").CanonicalName}

If you've done all the basic types & the corresponding types under OneDrve, the output will look like this:

PS C:\> (Get-Item 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults').Property |
>>    %{(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\$_").CanonicalName}
Downloads
Generic
Documents
Music
Pictures
Videos
StorageProviderGeneric
StorageProviderDocuments
StorageProviderPictures
StorageProviderVideos
StorageProviderMusic
PS C:\>

Appoly to Folders, will affect previously saved Explorer views but not previously saved Common Dialog views, so to ensure your prefences are applied to dialogs as well, run the following code:

$Defaults = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Defaults'
$Bags     = 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags'
$Custom = ( gi $Defaults ).Property
( gci $Bags -Recurse -depth 1 | ? PSChildName -match 'ComDlg' ) |
    gci | ? PSChildName -in $Custom |
        Remove-Item -Recurse

If you want to customize defaults for SearchResults & LIbraires as well, we have to create registry entries that don't normally exist, but see how the above works out for you first.

Related Question