|
@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 |