Disable Explorer Automatic Folder Discovery

config/tweaks.json
2620  "WPFTweaksDisableExplorerAutoDiscovery": {
2621    "Content": "Disable Explorer Automatic Folder Discovery",
2622    "Description": "Windows Explorer automatically tries to guess the type of the folder based on its contents, slowing down the browsing experience.",
2623    "category": "Essential Tweaks",
2624    "panel": "1",
2625    "InvokeScript": [
2626      "
2627      # Previously detected folders
2628      $bags = \"HKCU:\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\Bags\"
2629
2630      # Folder types lookup table
2631      $bagMRU = \"HKCU:\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\BagMRU\"
2632
2633      # Flush Explorer view database
2634      Remove-Item -Path $bags -Recurse -Force
2635      Write-Host \"Removed $bags\"
2636
2637      Remove-Item -Path $bagMRU -Recurse -Force
2638      Write-Host \"Removed $bagMRU\"
2639
2640      # Every folder
2641      $allFolders = \"HKCU:\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\Bags\\AllFolders\\Shell\"
2642
2643      if (!(Test-Path $allFolders)) {
2644        New-Item -Path $allFolders -Force
2645        Write-Host \"Created $allFolders\"
2646      }
2647
2648      # Generic view
2649      New-ItemProperty -Path $allFolders -Name \"FolderType\" -Value \"NotSpecified\" -PropertyType String -Force
2650      Write-Host \"Set FolderType to NotSpecified\"
2651
2652      Write-Host Please sign out and back in, or restart your computer to apply the changes!
2653      "
2654    ],
2655    "UndoScript": [
2656      "
2657      # Previously detected folders
2658      $bags = \"HKCU:\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\Bags\"
2659
2660      # Folder types lookup table
2661      $bagMRU = \"HKCU:\\Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\BagMRU\"
2662
2663      # Flush Explorer view database
2664      Remove-Item -Path $bags -Recurse -Force
2665      Write-Host \"Removed $bags\"
2666
2667      Remove-Item -Path $bagMRU -Recurse -Force
2668      Write-Host \"Removed $bagMRU\"
2669
2670      Write-Host Please sign out and back in, or restart your computer to apply the changes!
2671      "
2672    ],