New
#10
OK. Here it is. Enjoy!SpacemanSam said:
Using a 3rd-party program (SetACL by Helge Klein), I was able to take possession of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000} and delete the GroupBy value. I added it to my ConfigureWindow.bat setup file and tested it on a fresh W10 install, and it works - the Downloads directory now opens with filenames sorted in normal alphabetical order. :)
I'd like to do it without using any 3rd-party programs, but I haven't found anything that works yet. Powershell has Get-ACL and Set-ACL, but when I tried using them, I got permission errors. None of the samples I've found so far have worked. Considering that Helge Klein's SetACL program does work and is free to download, it may not be worth the effort to pursue this much further.
I can post the code for you if you'd like to include it in your tutorial. What's the best way to do that?
Great news. You can post it here if you like.
This batch file removes the "GroupBy" value from the default Explorer template for Downloads directories. After you run it, any Downloads directories which have never been already opened in Explorer will open without grouping. It does not remove the grouping from directory windows which have been opened in Explorer already, as the current layout for each Explorer window is stored in HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags in encoded form. It also does not prevent you from enabling grouping for any Explorer window if you want to.
Instructions:
1 If you have not done so already, create a directory on your data drive to hold Windows setup tweaks. I called it D:\ConfigureWindows, but you can use any name you want. Just don't put it in your Downloads directory!
2 Open Explorer and navigate to D:\ConfigureWindows. Create a new batch file here and call it RemoveGroupBy.bat. Open the file in Notepad, copy this code, paste it into Notepad and save it. Or click the "Download" button below.
Code:REM RemoveGroupBy.bat REM Remove "Group By Date" from Downloads directories @TITLE %~nx0 REM Do we have admin rights? openfiles >NUL: 2>&1 || @(ECHO; & <nul: set /p "junk=This script must be run as administrator! Press any key to exit... " & pause >NUL: & exit /b 2) REM Make sure SetACL.exe exists IF EXIST "%windir%\System32\SetACL.exe" GOTO :HaveSetACL REM Which version of SetACL should we use (32 bit or 64 bit)? IF DEFINED ProgramFiles(x86) ( SET "SetAcl=%~dp0SetACL (executable version)\64 bit\SetACL.exe" ) ELSE ( SET "SetAcl=%~dp0SetACL (executable version)\32 bit\SetACL.exe" ) IF NOT EXIST "%SetACL%" @(<nul: set /p junk=I can't find "%SetACL%". Press any key to exit. & PAUSE >NUL: & EXIT /B 2) COPY /Y "%SetACL%" %windir%\System32 SET SetAcl= :HaveSetACL REM Now let's get down to work! SET W64= :W64loop SET GBKey="HKLM\SOFTWARE%W64%\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" REG QUERY %GBKey% /V "GroupBy" >NUL: 2>&1 && ( REM Save the permissions on GBKey, then take ownership and enable the Delete permission SetACL -on %GBKey% -ot reg -actn list -bckp "%TEMP%\GroupBy.txt" SetACL -on %GBKey% -ot reg -actn setowner -ownr "n:S-1-5-32-544" SetACL -on %GBKey% -ot reg -actn setprot -actn ace -ace "n:S-1-5-32-544;p:full" REG DELETE %GBKey% /V "GroupBy" /F || PAUSE REM Restore the saved permissions on GroupByKey SetACL -on %GBKey% -ot reg -actn restore -bckp "%TEMP%\GroupBy.txt" DEL "%TEMP%\GroupBy.txt" ) IF NOT DEFINED W64 IF DEFINED ProgramFiles(x86) SET "W64=\WOW6432Node" & GOTO :W64loop SET W64= SET GBKey= IF /I "%~1" NEQ "NOPAUSE" PAUSE EXIT /B 0
Download
3 Open a browser window / tab and navigate to Helge Klein's website to download the EXE version of SetACL. Choose either the 32-bit or 64-bit version as appropriate. UnZip the download into your ConfigureWindows directory. Verify that "ConfigureWindows\SetACL (executable version)" contains ether the "32 bit" or "64 bit" subdirectory. (I have sometimes seen .zip files unzip into two levels instead of just one. If that happens, RemoveGroupBy.bat won't be able to find SetACL.exe.) If you plan on using this on both 32-bit and 64-bit Windows, download both versions. Be sure to keep them separate!
4 To run this tweak immediately, right-click on RemoveGroupBy.bat and select "Run as administrator".
5 If you want to run this tweak (and any others) automatically on any fresh install or update, create a batch file in D:\ConfigureWindows that will run all of them in one swell foop. (Suggested name: ConfigureWindows.bat.) In this file, put the following lines:
Of course, ConfigureWindows.bat should also contain any other tweaks you want to apply at the same time. Tenforums.com has a plethora of tweaks you'll probably want to include!Code:CALL "%~dp0RemoveGroupBy.bat" nopause || @((IF %ERRORLEVEL% EQU 1 ECHO; & <nul: set /p junk=%~dp0RemoveGroupBy.bat not found! Press any key to exit... & PAUSE >NUL:) & EXIT /B 2) @TITLE %~nx0
Future enhancement: The registry key to patch is hard-coded in this batch file. If I find any others that require patching in the same way, I might modify the batch file to take the key (and maybe the value) as parameters, or perhaps make the part that does the job into a subroutine that can be called with several values for the registry key.
Finally: This tweak only removes "GroupBy" from the template used to open new Download directories for the first time. It does not affect any directory windows that have previously been opened in Explorer. I might write a script to loop through ...\Shell\Bags and change the GroupByKey:FMTID and GroupByKey:PID values for Downloads directory windows. But that's another project - stay tuned!
Last edited by SpacemanSam; 05 Apr 2022 at 19:31. Reason: Fixed test for 64bit OS