Optimize the registry and delete unnecessary logs and backups

AeonX

Well-Known Member
NTLite could have the option to optimize the registry by exporting the hives to reduce the size of the files.


And it could also delete some unnecessary files in \Windows\System32\config\

yVESWcH.png


YaquN25.png


zMrlcBp.png


OHxQYXI.png
 
I did a batch script for that. I mount the image and paste the path into it :)

Before:
2021-05-23 05_26_03.png

Later:
2021-05-23 05_26_41.png

Batch:
Code:
@echo off

:: Checking administrative rights
reg query HKU\S-1-5-19 >nul 2>&1 || (echo Run as Administrator & goto end)

set /p "mount=Mounted image path: "

if not defined mount goto end
if not exist "%mount%\Windows\System32\config\" echo Invalid path & goto end

echo.
echo Compressing registry hives
reg load HKLM\Temp "%mount%\Users\Default\NTUSER.DAT" >nul
reg save HKLM\Temp "%mount%\Users\Default\compressedhive" /c >nul
reg unload HKLM\Temp >nul
move /y "%mount%\Users\Default\compressedhive" "%mount%\Users\Default\NTUSER.DAT" >nul
for %%G in (COMPONENTS,DEFAULT,DRIVERS,SOFTWARE,SYSTEM) do (
  if exist "%mount%\Windows\System32\config\%%G" (
    reg load HKLM\Temp "%mount%\Windows\System32\config\%%G" >nul
    reg save HKLM\Temp "%mount%\Windows\System32\config\compressedhive" /c >nul
    reg unload HKLM\Temp >nul
    move /y "%mount%\Windows\System32\config\compressedhive" "%mount%\Windows\System32\config\%%G" >nul
  )
)

echo.
echo Deleting registry logs
call :clean "%mount%\Users\Default"
call :clean "%mount%\Windows\System32\config"
echo.
echo Done.
goto end

:clean
set "_path=%~1"
if exist "%_path%\*.LOG1" attrib -S -H "%_path%\*.LOG1" & del /f /q "%_path%\*.LOG1"
if exist "%_path%\*.LOG2" attrib -S -H "%_path%\*.LOG2" & del /f /q "%_path%\*.LOG2"
if exist "%_path%\*.TM.blf" attrib -S -H "%_path%\*.TM.blf" & del /f /q "%_path%\*.TM.blf"
if exist "%_path%\*.regtrans-ms" attrib -S -H "%_path%\*.regtrans-ms" & del /f /q "%_path%\*.regtrans-ms"
set "_path="
goto :eof

:end
echo.
echo Press any key to exit.
pause >nul
exit
 
Interesting, I think log files removal is in “Temporary and log files” component. If not it should be improved. nuhi can you please confirm it?
 
Back
Top