From 9cc85ed3583fa157ebc9bc8f1c0ea34a717ec6b8 Mon Sep 17 00:00:00 2001 From: Belim Date: Fri, 17 Feb 2023 16:19:50 +0100 Subject: [PATCH] Add files via upload --- mods/Clean-up Windows.ini | 13 ++++++++++ mods/clean-up_windows.ps1 | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 mods/Clean-up Windows.ini create mode 100644 mods/clean-up_windows.ps1 diff --git a/mods/Clean-up Windows.ini b/mods/Clean-up Windows.ini new file mode 100644 index 0000000..a617f56 --- /dev/null +++ b/mods/Clean-up Windows.ini @@ -0,0 +1,13 @@ +[Info] +DisplayName=Run Microsoft Disk Clean-up aka cleanmgr.exe +Publisher=https://stackoverflow.com/questions/40534323/windows-update-cleanup-in-registry-editor/40537520#40537520 +AboutScript=This will use classic Disk clean-up utility aka Cleanmgr.exe to clear unnecessary files from your computer's hard disk instead of Microsoft's replacement "Storage Sense app" which is part of the Settings app. This script will use command-line options to specify that Cleanmgr.exe cleans up all areas expect Recycle Bin and Previous Windows Installations. +ScriptLanguage=PowerShell +ConditionScript=clean-up_windows.ps1 +CreateNoWindow=true + + + + + + diff --git a/mods/clean-up_windows.ps1 b/mods/clean-up_windows.ps1 new file mode 100644 index 0000000..05c1fa8 --- /dev/null +++ b/mods/clean-up_windows.ps1 @@ -0,0 +1,54 @@ +Requires -RunAsAdministrator + +$SageSet = "StateFlags0099" +$Base = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\" +$Locations= @( + "Active Setup Temp Folders" + "BranchCache" + "Downloaded Program Files" + "GameNewsFiles" + "GameStatisticsFiles" + "GameUpdateFiles" + "Internet Cache Files" + "Memory Dump Files" + "Offline Pages Files" + "Old ChkDsk Files" + "D3D Shader Cache" + "Delivery Optimization Files" + "Diagnostic Data Viewer database files" + #"Previous Installations" + #"Recycle Bin" + "Service Pack Cleanup" + "Setup Log Files" + "System error memory dump files" + "System error minidump files" + "Temporary Files" + "Temporary Setup Files" + "Temporary Sync Files" + "Thumbnail Cache" + "Update Cleanup" + "Upgrade Discarded Files" + "User file versions" + "Windows Defender" + "Windows Error Reporting Archive Files" + "Windows Error Reporting Queue Files" + "Windows Error Reporting System Archive Files" + "Windows Error Reporting System Queue Files" + "Windows ESD installation files" + "Windows Upgrade Log Files" +) + +# -ea silentlycontinue will supress error messages +ForEach($Location in $Locations) { + Set-ItemProperty -Path $($Base+$Location) -Name $SageSet -Type DWORD -Value 2 -ea silentlycontinue | Out-Null +} + +# Do the clean-up. Have to convert the SageSet number +$Args = "/sagerun:$([string]([int]$SageSet.Substring($SageSet.Length-4)))" +Start-Process -Wait "$env:SystemRoot\System32\cleanmgr.exe" -ArgumentList $Args + +# Remove the Stateflags +ForEach($Location in $Locations) +{ + Remove-ItemProperty -Path $($Base+$Location) -Name $SageSet -Force -ea silentlycontinue | Out-Null +}