Updated 12/06/2020 - A new registry key gets added that contains both the function's last run time as well as the StateFlags integer value. Each time the function is run, it checks this registry key and ensures none of the previous StateFlags' integer values are still present. This will ensure any set StateFlags integer values are removed if the clean-up process is exited or closed before the Windows Disk Clean-up utility has completed. - Included the removal of additional histories and recent documents. - Additional primary function and helper function updates and improvements. Updated 08/26/2020 - The OS is now checked before removing shadow copies (restore points) to make sure it is not a version of Windows Server. - Added additional default and Microsoft Edge removal paths. - Added the clearing of the App Compat Cache and CD burning registry keys. I cannot post the full code of the module any longer due to exceeding the character limit for a single post, but I created a GitHub Gist for it where you can view it and download it: Start-WindowsCleanup on GitHub
I would love to see bat/cmd versions(cos i know my way around them) of powersmell stuff but you have to accept and respect a developers choice. We have 2 choices, try to create our own bats or learn powersmell.
GUI's <and / or> bat/cmd scripts to be able to use @GodHand powershell scripts would be Greatly Appreciated since NOT every MDL member is a powershell expert or even remotely close to being one...
You do not have to be anywhere close to a "PowerShell expert" to run any of the functions I post - that's why I post them. Functions can be copied and then pasted right into an elevated PowerShell console and then executed by typing the function name, or they can be saved saved to a .ps1 file and called directly within a PowerShell console like you'd call one batch script from another.
Knowing something works isnt enough for me, i like to know how and why, thats how i learnt the basics of bat's and cmd's.
Just out of interest @GodHand, do you know of a tool that converts bats and cmds to powershell? I prefer to use one type of file only and combine stuff into 1 large script rather than seperate bats/cmds and powershells.
There is no tool that can do that. PowerShell code logic and syntax are completely different and you can't just convert it - you have to rewrite it. You can execute bat/cmd scripts within PowerShell and monitor them using many PowerShell's cmdlets, though, which is not hard. Likewise, you can encode PowerShell scripts and execute them within bat/cmd scripts. If you are interested in learning and knowing the 'how and why,' why are you asking me to create a version in a depreciated format for you instead of taking the time to look at the code to understand exactly what it's doing? It's not a complicated function.
Im not. You create a PS script in that format only as is your right to do so i want to learn PS so i know what you do and how you do it. Im backing you on your choice of PS scripts only, im on your side.
Updated 11-14-2019: Added additional logging and update clean-up locations. Tweaked the preclean-up and post clean-up results that get returned. Added some code changes and optimizations.
Updated 01-16-2020: - Added additional directories for removal. - Added methods to clean-up the component store and/or reset the image base using a background job. - Added a timed pop-up verification for the removal of download folders' contents in case it was accidentally entered when calling the function. - Assorted other code changes.
@vigipirate @rayleigh_otter @MMIKEE Batch script to call Powershell function, Save the Powershell (.ps1) script and batch script (.cmd) in the same directory. Code: @echo off reg query HKU\S-1-5-19 1>nul 2>nul || ( echo ==== Error ==== echo Right click on this file and select 'Run as administrator' echo Press any key to exit... pause >nul exit /b ) REM File name Function name powershell -ExecutionPolicy ByPass -command ". "%~dp0Start-WindowsCleanup.ps1"; Start-WindowsCleanup;" pause It works with GodHand's other script too, P.S. To avoid any possible errors, make sure that the pathname does not have spaces or special characters.