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!

1 comment:

  1. Anonymous18/1/23 08:02

    This article has proven to be very helpful to me. Articles as such might be much helpful to you to enhance your knowledge base. You shall learn a lot from this. They provides valuable information.
    Should you feel any interest in visiting the site? The link is given below
    Xiaomi Redmi 10C will be available soon in local market

    ReplyDelete