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,707 of 197,590   
   NewsKrawler to Paul   
   Re: W10's Disk Cleanup (cleanmgr.exe) ca   
   21 Nov 25 01:57:53   
   
   From: newskrawl@krawl.org   
      
   On Wed, 12 Nov 2025 17:59:53 -0500, Paul wrote:   
   >   # In an administrator terminal   
   >   dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase   
      
   I wrote this today to clean up a 32GB ssd C: drive.   
   Maybe we can add the commands that the others suggested for Ant.   
      
    @echo off   
    :: 20251120 cleanpc.bat Clean a laptop with a permanent 32GB ssd C:   
    :: 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   
    :: 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   
    )   
      
    :: 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   
      
    :: 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   
    for /f "tokens=*" %%i in ('compact.exe /compactOS:query') do (   
        echo %%i | findstr /C:"Compact state" >nul   
        if not errorlevel 1 (   
            echo %%i   
            echo CompactOS status checked.   
        )   
    )   
      
    :: Enable CompactOS if not already enabled   
    compact.exe /compactOS:always   
      
    :: Report result   
    for /f "tokens=*" %%i in ('compact.exe /compactOS:query') do (   
        echo %%i | findstr /C:"Compact state" >nul   
        if not errorlevel 1 (   
            echo Final %%i   
        )   
    )   
      
    :: Windows.old cleanup (if present after upgrades)   
    if exist C:\Windows.old (   
        echo Removing Windows.old folder...   
        rd /s /q "C:\Windows.old"   
    )   
      
    :: Check free space again after Windows.old removal   
    for /f "skip=1 tokens=2 delims==" %%a in ('wmic logicaldisk where   
   "DeviceID='C:'" get FreeSpace /value') do set FreeSpaceFinal=%%a   
    set /a FreeSpaceFinalMB=%FreeSpaceFinal:~0,-6%   
      
      
   [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