home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.comp.os.windows-10      Steaming pile of horseshit Windows 10      197,590 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 195,708 of 197,590   
   NewsKrawler to Ant   
   Re: W10's Disk Cleanup (cleanmgr.exe) ca   
   21 Nov 25 03:40:20   
   
   From: newskrawl@krawl.org   
      
   On Wed, 12 Nov 2025 19:51:07 -0000 (UTC), Ant wrote:   
      
   > I was expecting all of that to be cleaned up.   
      
   I wrote a script to clean up the PC & posted it   
   earlier but then I updated it again so you might   
   want to try this one, which is the third version.   
      
   The previous script always ran compression   
   but this script checks if the compression has   
   already been run, saving a lot of time.   
      
   It uses cleanmgr in a couple of places that I   
   was cleaning up with basic Windows commands,   
   but cleanmgr is safer, but now it requires   
   user interaction (but it's safer for you now).   
      
    @echo off   
    :: 20251121 cleanpc.bat version 1.3   
    :: Clean a laptop with a permanent 32GB ssd C:   
    :: After running cleanmgr   
    :: 1. Disable hibernation (hiberfil.sys)   
    :: 2. Clear user & system temp   
    :: 3. Clear Prefetch & Windows logs & Panther logs (they regenerate)   
    :: 4. Delete all restore points (vssadmin delete shadows)   
    :: 5. Purge Windows Update cache   
    :: 6. Empty Recycle Bin   
    :: 7. Run DISM component cleanup   
    :: 8. Remove Windows.old if present   
    :: 9. Summarize & date results   
    :: WIP one-time events   
    :: Set all Wi-Fi & Ethernet connections as metered to discourage updates   
    :: Run sfc /scannow to check system files against known good versions   
    :: Run DISM /Online /Cleanup-Image /CheckHealth   
    :: Run DISM /Online /Cleanup-Image /ScanHealth   
    :: Win+R then services.msc then disable Windows Update (wuauserv)   
    :: Set Wi-Fi as metered connection   
    :: Disable scheduled tasks in UpdateOrchestrator   
    :: Task Scheduler Library > Microsoft > Windows > UpdateOrchestrator   
    ::   Disable Schedule Scan & UpdateModel & USO_UxBroker & Reboot   
    :: Disable hibernation to reclaim several GB with powercfg -h off   
    :: Move pagefile.sys to D: via Virtual Memory settings   
    :: sysdm.cpl > Advnced > Performance [Settings]   
    ::  Performance Options > Advanced tab > Virtual Memory [Change]   
    ::  [_]Automatically manage paging file size for all drives   
    ::  C: drive > No paging file > Set   
    ::  D: drive > System managed size (recommended) > Set   
    ::  But that won't work with sd cards nor non-ntfs fixed drives   
    ::   
    :: Move & symlink OEM recovery files like usmt.ppkg to D:   
    :: System Properties > Performance > Advanced > Virtual Memory   
    :: Win+R then control > System and Security > System Protection > Configure   
    ::   
    :: Notes   
    :: Prefetch & log files will regenerate after use so deletion is temporary   
    :: DISM /ResetBase locks you into current update level with no uninstall   
    :: Restore points are deleted so rollback is not possible after cleanup   
    :: CompactOS may already be enabled so compression may not free extra space   
    :: UpdateOrchestrator tasks vary by Windows version so some may not exist   
    :: or may resist disabling even with admin rights   
    ::   
    :: Admin check (auto-elevate if not run as admin)   
    net session >nul 2>&1   
    if %errorlevel% neq 0 (   
        echo Requesting administrator privileges...   
        powershell -Command "Start-Process '%~f0' -Verb RunAs"   
        exit /b   
    )   
      
    systeminfo | findstr /C:"Total Physical Memory"   
      
    :: Check drive size and free space before cleanup   
    for /f "skip=1 tokens=2 delims==" %%a in ('wmic logicaldisk where   
   "DeviceID='C:'" get Size /value') do set DriveSize=%%a   
    set /a DriveSizeMB=%DriveSize:~0,-6%   
      
    for /f "skip=1 tokens=2 delims==" %%a in ('wmic logicaldisk where   
   "DeviceID='C:'" get FreeSpace /value') do set FreeSpaceBefore=%%a   
    set /a FreeSpaceBeforeMB=%FreeSpaceBefore:~0,-6%   
      
    echo Drive size: %DriveSizeMB% MB   
    echo Free space before cleanup: %FreeSpaceBeforeMB% MB   
      
    :: Show percentage used/free before cleanup   
    set /a UsedSpaceBeforeMB=%DriveSizeMB%-%FreeSpaceBeforeMB%   
    set /a PercentUsedBefore=(%UsedSpaceBeforeMB%*100)/%DriveSizeMB%   
    set /a PercentFreeBefore=(%FreeSpaceBeforeMB%*100)/%DriveSizeMB%   
    echo Drive usage before cleanup: %PercentUsedBefore%%% used, %P   
   rcentFreeBefore%%% free   
      
    :: Start cleaning   
    echo Cleaning temporary files...   
      
    :: Disable hibernation to remove hiberfil.sys (saves several GB)   
    powercfg -h off   
      
    :: Run Disk Cleanup silently using saved selections (ID 99)   
    cleanmgr.exe /sagerun:99   
    cleanmgr.exe /d C: /VERYLOWDISK   
      
    :: User Temp   
    if exist %TEMP% (   
        del /q/f/s "%TEMP%\*" 2>nul   
        rd /s /q "%TEMP%" 2>nul   
    )   
      
    :: System Temp   
    if exist C:\Windows\Temp (   
        del /q/f/s "C:\Windows\Temp\*" 2>nul   
        rd /s /q "C:\Windows\Temp" 2>nul   
    )   
      
    :: Prefetch cleanup   
    if exist C:\Windows\Prefetch (   
        del /q/f/s "C:\Windows\Prefetch\*" 2>nul   
    )   
      
    :: Windows Logs cleanup   
    if exist C:\Windows\Logs (   
        del /q/f/s "C:\Windows\Logs\*" 2>nul   
    )   
      
    :: Panther setup logs cleanup   
    if exist C:\Windows\Panther (   
        del /q/f/s "C:\Windows\Panther\*" 2>nul   
    )   
      
    :: Delete all restore points   
    vssadmin delete shadows /all /quiet   
      
    :: Disable UpdateOrchestrator scheduled tasks to discourage auto updates   
    echo Disabling UpdateOrchestrator tasks...   
    set TaskRoot=\Microsoft\Windows\UpdateOrchestrator   
      
    :: Schedule Scan   
    schtasks /Query /TN "%TaskRoot%\Schedule Scan" >nul 2>&1   
    if %errorlevel%==0 (   
        schtasks /Change /TN "%TaskRoot%\Schedule Scan" /Disable   
        if %errorlevel%==0 (echo Schedule Scan disabled successfully) else (echo   
   Failed to disable Schedule Scan)   
    ) else (   
        echo Schedule Scan task not found   
    )   
      
    :: UpdateModel   
    schtasks /Query /TN "%TaskRoot%\UpdateModel" >nul 2>&1   
    if %errorlevel%==0 (   
        schtasks /Change /TN "%TaskRoot%\UpdateModel" /Disable   
        if %errorlevel%==0 (echo UpdateModel disabled successfully) else (echo   
   Failed to disable UpdateModel)   
    ) else (   
        echo UpdateModel task not found   
    )   
      
    :: USO_UxBroker   
    schtasks /Query /TN "%TaskRoot%\USO_UxBroker" >nul 2>&1   
    if %errorlevel%==0 (   
        schtasks /Change /TN "%TaskRoot%\USO_UxBroker" /Disable   
        if %errorlevel%==0 (echo USO_UxBroker disabled successfully) else (echo   
   Failed to disable USO_UxBroker)   
    ) else (   
        echo USO_UxBroker task not found   
    )   
      
    :: Reboot   
    schtasks /Query /TN "%TaskRoot%\Reboot" >nul 2>&1   
    if %errorlevel%==0 (   
        schtasks /Change /TN "%TaskRoot%\Reboot" /Disable   
        if %errorlevel%==0 (echo Reboot task disabled successfully) else (echo   
   Failed to disable Reboot task)   
    ) else (   
        echo Reboot task not found   
    )   
      
    :: Continue with deeper cleanup (Windows Update cache, Recycle Bin, DISM)   
    sc query wuauserv | find "STATE" >nul   
      
    if %errorlevel%==0 (   
        net stop wuauserv   
        rd /s /q "C:\Windows\SoftwareDistribution" 2>nul   
        net start wuauserv   
    ) else (   
        echo Windows Update service is disabled, skipping cache cleanup.   
    )   
      
    :: Empty Recycle Bin   
    if exist C:\$Recycle.bin rd /s /q "C:\$Recycle.bin" 2>nul   
      
    :: Run DISM cleanup (either just remove or lock at the current level)   
    :: dism /Online /Cleanup-Image /StartComponentCleanup   
    :: /ResetBase locks you into the current version   
    dism /Online /Cleanup-Image /StartComponentCleanup /ResetBase   
      
    :: Check CompactOS status   
      
   [continued in next message]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca