Skip to content

Instantly share code, notes, and snippets.

@avisek
Created April 25, 2026 15:58
Show Gist options
  • Select an option

  • Save avisek/f6d229d35e115ba7972a1f54464ef3cf to your computer and use it in GitHub Desktop.

Select an option

Save avisek/f6d229d35e115ba7972a1f54464ef3cf to your computer and use it in GitHub Desktop.
Force Windows Explorer to always use Details view (General Items) and disable automatic folder type detection system-wide.

🗂️ Force Windows Explorer to Always Use “Details” View (System-Wide)

This script disables Windows File Explorer’s automatic folder type detection and forces a consistent view across all folders.

By default, Windows analyzes the contents of each folder and dynamically switches layouts (e.g., thumbnails for images, music columns for audio). This behavior can be inconsistent and frustrating—especially if you prefer a uniform browsing experience.

This script enforces a single, consistent configuration:

  • View: Details
  • Template: General Items
  • Applies to: All folders, regardless of content

⚙️ What it does

  • Disables automatic folder type discovery
  • Resets and standardizes all Explorer folder view settings
  • Forces:
    • Details view (Mode = 4)
    • General Items (FolderType = NotSpecified)
  • Clears existing Bags and BagMRU cache to prevent overrides
  • Increases folder view cache size for stability
  • Applies changes:
    • To all existing users
    • To the current user
    • To the default profile (affects future users)
  • Automatically restarts Explorer to apply changes

🚀 Usage

  1. Download the script
  2. Double-click to run
  3. Accept the UAC prompt (admin required)

No manual configuration needed. The script is fully portable and can be used on other machines.


⚠️ Notes

  • This will reset all custom folder view settings system-wide
  • Some special locations (e.g., MTP devices) may not fully respect these settings due to Windows limitations
  • A restart of Explorer is performed automatically

🎯 Why use this?

If you:

  • Prefer a clean, consistent Details view
  • Dislike Windows randomly changing folder layouts
  • Want a set-it-and-forget-it solution across all users

…this script solves that problem in one step.

@echo off
setlocal EnableExtensions EnableDelayedExpansion
REM ================================================================
REM Force Details View / General Items Template - System-Wide
REM ================================================================
REM Disables Windows folder type discovery and forces every folder
REM (including MTP devices and network locations) to use the
REM General Items template in Details view.
REM
REM Applies to: every existing user + the Default profile (so any
REM future user account on this PC inherits the same setting).
REM
REM Just double-click this .bat file; the UAC prompt will appear.
REM ================================================================
REM --- Self-elevate ----------------------------------------------------
net session >nul 2>&1
if %errorlevel% NEQ 0 (
echo Requesting administrator privileges...
powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
title Force Details View - System-Wide
echo.
echo ===============================================================
echo Force General Items / Details View on All Folders
echo Affects: every existing user + Default profile (future users)
echo ===============================================================
echo.
REM --- Stop Explorer so it releases the bag cache ---------------------
echo [1/4] Stopping File Explorer...
taskkill /f /im explorer.exe >nul 2>&1
timeout /t 2 /nobreak >nul
REM --- Apply to Default user template (future accounts) ---------------
echo [2/4] Applying to Default profile (template for future users)...
set "DEFAULT_HIVE=%SystemDrive%\Users\Default\NTUSER.DAT"
if exist "%DEFAULT_HIVE%" (
reg load "HKU\_DefaultTpl" "%DEFAULT_HIVE%" >nul 2>&1
if !errorlevel! EQU 0 (
call :ApplyHive "HKU\_DefaultTpl"
reg unload "HKU\_DefaultTpl" >nul 2>&1
echo OK
) else (
echo [!] Default hive could not be loaded.
)
) else (
echo [!] Default NTUSER.DAT not found at %DEFAULT_HIVE%.
)
REM --- Apply to existing user profiles --------------------------------
echo [3/4] Applying to existing user profiles...
for /f "tokens=*" %%U in ('dir /b /a:d "%SystemDrive%\Users" 2^>nul') do (
set "U=%%U"
set "SKIP=0"
if /I "!U!"=="Default" set "SKIP=1"
if /I "!U!"=="Default User" set "SKIP=1"
if /I "!U!"=="Public" set "SKIP=1"
if /I "!U!"=="All Users" set "SKIP=1"
if /I "!U!"=="DefaultAppPool" set "SKIP=1"
if "!SKIP!"=="0" (
set "HV=%SystemDrive%\Users\%%U\NTUSER.DAT"
if exist "!HV!" (
reg load "HKU\_TmpUser" "!HV!" >nul 2>&1
if !errorlevel! EQU 0 (
echo - %%U
call :ApplyHive "HKU\_TmpUser"
reg unload "HKU\_TmpUser" >nul 2>&1
) else (
echo - %%U ^(hive in use - handled in next pass^)
)
)
)
)
REM --- Apply to currently loaded user hives (logged-in users) ---------
echo Applying to currently loaded user hives...
for /f "tokens=*" %%S in ('reg query HKU 2^>nul') do (
set "K=%%S"
echo !K! | findstr /R "S-1-5-21-[0-9][0-9]*-[0-9][0-9]*-[0-9][0-9]*-[0-9][0-9]*$" >nul
if !errorlevel! EQU 0 (
echo - !K!
call :ApplyHive "!K!"
)
)
REM --- Restart Explorer -----------------------------------------------
echo [4/4] Restarting File Explorer...
start "" explorer.exe
echo.
echo ===============================================================
echo Done.
echo.
echo All folders, MTP devices and network locations will now use
echo the General Items template in Details view.
echo.
echo If a folder still shows the old layout, open it once and
echo press F5; the new view will be remembered from then on.
echo ===============================================================
echo.
pause
exit /b 0
REM =====================================================================
REM :ApplyHive <RegRoot>
REM Resets remembered views and forces General Items / Details on the
REM given registry root (e.g. HKU\_TmpUser or HKU\S-1-5-21-...).
REM =====================================================================
:ApplyHive
set "R=%~1"
REM Wipe per-folder remembered views (Bags) so Windows starts fresh
reg delete "%R%\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags" /f >nul 2>&1
reg delete "%R%\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU" /f >nul 2>&1
reg delete "%R%\Software\Microsoft\Windows\Shell\Bags" /f >nul 2>&1
reg delete "%R%\Software\Microsoft\Windows\Shell\BagMRU" /f >nul 2>&1
reg delete "%R%\Software\Microsoft\Windows\ShellNoRoam\Bags" /f >nul 2>&1
reg delete "%R%\Software\Microsoft\Windows\ShellNoRoam\BagMRU" /f >nul 2>&1
REM Increase BagMRU capacity so views aren't dropped over time
reg add "%R%\Software\Microsoft\Windows\Shell" /v "BagMRU Size" /t REG_DWORD /d 20000 /f >nul 2>&1
reg add "%R%\Software\Microsoft\Windows\ShellNoRoam" /v "BagMRU Size" /t REG_DWORD /d 20000 /f >nul 2>&1
REM ---- Force every folder to the General Items template -------------
REM "NotSpecified" tells Explorer NOT to auto-detect a folder type.
reg add "%R%\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell" /v "FolderType" /t REG_SZ /d "NotSpecified" /f >nul 2>&1
REM Pre-seed the AllFolders bag with Details view
REM Mode = 4 -> Details
REM LogicalViewMode = 1 -> Details
reg add "%R%\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell" /v "Mode" /t REG_DWORD /d 4 /f >nul 2>&1
reg add "%R%\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell" /v "LogicalViewMode" /t REG_DWORD /d 1 /f >nul 2>&1
exit /b 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment