# Run as Administrator! Write-Host "🧽 Starting full system cleanup..." -ForegroundColor Cyan # Stop Windows Update service Stop-Service -Name wuauserv -Force -ErrorAction SilentlyContinue # Clear SoftwareDistribution folders Remove-Item "C:\Windows\SoftwareDistribution\Download\*" -Recurse -Force -ErrorAction SilentlyContinue Remove-Item "C:\Windows\SoftwareDistribution\DataStore\*" -Recurse -Force -ErrorAction SilentlyContinue # Clear update logs $updateLogs = @( "C:\Windows\Logs\CBS\*", "C:\Windows\Logs\DISM\*", "C:\Windows\Panther\*" ) foreach ($log in $updateLogs) { Remove-Item -Path $log -Recurse -Force -ErrorAction SilentlyContinue } # Clear temp folders $tempDirs = @("$env:USERPROFILE\AppData\Local\Temp", "$env:windir\Temp") foreach ($dir in $tempDirs) { Get-ChildItem -Path $dir -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue } # Restart Windows Update Start-Service -Name wuauserv # Trigger Disk Cleanup profile Write-Host "Launching Disk Cleanup profile setup..." -ForegroundColor Yellow Start-Process "cleanmgr.exe" -ArgumentList "/sageset:99" -Verb RunAs Write-Host "`nšŸ“ Please select cleanup options in the Disk Cleanup window that appears, then press OK." Write-Host "Once done, re-run: cleanmgr.exe /sagerun:99 to execute the selected cleanup tasks." -ForegroundColor Cyan #1# Removing recycle bin files # Set the path to the recycle bin on the C drive $Path = 'C' + ':\$Recycle.Bin' # Get all items (files and directories) within the recycle bin path, including hidden ones Get-ChildItem $Path -Force -Recurse -ErrorAction SilentlyContinue | # Remove the items, excluding any files with the .ini extension Remove-Item -Recurse -Exclude *.ini -ErrorAction SilentlyContinue # Display a success message write-Host "All the necessary data removed from recycle bin successfully" -ForegroundColor Green #2# Remove Temp files from various locations write-Host "Erasing temporary files from various locations" -ForegroundColor Yellow # Specify the path where temporary files are stored in the Windows Temp folder $Path1 = 'C' + ':\Windows\Temp' # Remove all items (files and directories) from the Windows Temp folder Get-ChildItem $Path1 -Force -Recurse -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue # Specify the path where temporary files are stored in the Windows Prefetch folder $Path2 = 'C' + ':\Windows\Prefetch' # Remove all items (files and directories) from the Windows Prefetch folder Get-ChildItem $Path2 -Force -Recurse -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue # Specify the path where temporary files are stored in the user's AppData\Local\Temp folder $Path3 = 'C' + ':\Users\*\AppData\Local\Temp' # Remove all items (files and directories) from the specified user's Temp folder Get-ChildItem $Path3 -Force -Recurse -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue # Display a success message write-Host "removed all the temp files successfully" -ForegroundColor Green #3# Using Disk cleanup Tool # Display a message indicating the usage of the Disk Cleanup tool write-Host "Using Disk cleanup Tool" -ForegroundColor Yellow # Run the Disk Cleanup tool with the specified sagerun parameter cleanmgr /sagerun:1 | out-Null # Emit a beep sound using ASCII code 7 Write-Host "$([char]7)" # Pause the script for 5 seconds Sleep 5 # Display a success message indicating that Disk Cleanup was successfully done write-Host "Disk Cleanup Successfully done, to make sure just start again the Disk Clean Up Tool, press enter" -ForegroundColor Green pause cleanmgr.exe # Pause the script for 10 seconds Sleep 10