Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @(set "0=%~f0"^)#) & powershell -nop -c iex([io.file]::ReadAllText($env:0)) & exit /b
- $_Paste_in_Powershell = {
- $host.ui.rawui.windowtitle = 'WINDOWS UPDATE CLEANUP' # v2023.07.13
- write-host "ResetBase removes superseded components (quicker, but might break 'Reset this PC' feature)" -fore Gray
- write-host "Press [Y] to ResetBase, [N] to just cleanup components - selected in 10s:" -fore Green -nonew
- choice /n /t 10 /d N /m " "; $resetbase=$lastexitcode -ge 2; kill -name 'dism.exe','cleanmgr.exe' -force -ea 0
- if ($resetbase) {Dism /Online /Cleanup-Image /StartComponentCleanup /ResetBase}
- else {Dism /Online /Cleanup-Image /StartComponentCleanup}
- write-host "`nPlease wait while running Update Disk Cleanup. If it takes too long, Ctrl+C and relaunch" -fore Gray
- $clean = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches'
- $items = 'Update Cleanup','Temporary Setup Files','ServicePack Cleanup', # 'BranchCache','Delivery Optimization Files',
- 'System error memory dump files','System error minidump files','Windows Error Reporting Files','Windows Defender'
- foreach ($i in $(reg query "$clean")) {reg add "$i" /f /v StateFlags2022 /d 0 /t reg_dword >$null 2>&1}
- foreach ($i in $items) {reg add "$clean\$i" /f /v StateFlags2022 /d 2 /t reg_dword >$null}
- cleanmgr /sagerun:2022; while (get-process cleanmgr -ea 0) {sleep -m 1000}
- Dism /Online /Get-packages /Format:table
- Dism /Online /Cleanup-Image /AnalyzeComponentStore
- } ; start -verb runas powershell -args "-nop -noe -c & {`n`n$($_Paste_in_Powershell -replace '"','\"')}"
- $_Press_Enter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement