Search This Blog

Sunday, December 11, 2022

Windows: Clearing cache, temp files and logs

As a follow up to my previous maintenance post here are a few more advice that will help you clear out some cache primarily, it's not a way to clear much space. You might save up to a gigabyte depending on how long your computer has run without maintenance. Also check out my other post about maintenance.

The script goes as following and can be run by a normal user, it does not force the computer to delete anything that requires admin permissions in other words. So if an admin runs the script it will be even more powerful.

It will clear up logs and temp files, and then also clear the recycling bin. After which it will also clear up some cache.

$ErrorActionPreference = "SilentlyContinue"

Write-Output "Clearing DISM log..."
Get-ChildItem -Path C:\Windows\Logs\DISM | Remove-Item -Recurse

Write-Output "Clearing CBS log..."
Get-Childitem -Path C:\Windows\Logs\CBS | Remove-Item -Recurse

Write-Output "Clearing C:\Windows\Temp"
Get-ChildItem -Path C:\Windows\Temp | Remove-Item -Recurse

Write-Output "Clearing C:\...\AppData\Local\Temp"
$User = $env:username
Get-ChildItem -Path C:\Users\$User\AppData\Local\Temp | Remove-Item -Recurse

Write-Output "Clearing recycle bin"
Clear-RecycleBin -Force

Write-Output "Clearing DNS cache"
Clear-DnsClientCache

Write-Output "Resetting Microsoft Store"
wsreset
Start-Sleep -Milliseconds 700
Stop-Process -name "WinStore.App"

At the end of the script, Microsoft Store will pop up, I've included a line in the script that closes the app again, to leave the user with a more hands off execution.

You can also delete these items manually. For a manual cleanup you can also go to C:\Windows\LiveKernelReports\ and look for big .dmp files. These are dump files and can be investigated in case of a system crash for example. If you have no need to inspect these files you can delete them. I would avoid any folders or other files personally.

Enjoy!

Sunday, December 4, 2022

Registry: Show detailed Windows messages

Whenever you turn your computer on or off you can see messages such as "updating, please don't turn your computer off" at the boot screen.

Sometimes your computer can get stuck here or it takes a long time and you might wonder what is happening. Using the registry you can enable more detailed status messages at the boot up or restart.

Create a .reg-file with the following information:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]

“verbosestatus”=dword:00000001

Now you can see what the computer is doing when it previously only would indicate that it was working.