Windows.old is getting old…

Earlier today I was looking for a script to remove the c:\Windows.old directory from my computer following installation of a new version of Windows.  Unfortunately, in these times of “Windows 10 is the last desktop OS we will ever deliver, but we are updating it to a new version every six months,” this is needed now more than ever.

The script that I dug up I did not write.  I think I borrowed it from TechNet a few years ago.  However, it works well, so feel free to use it! -M

$path = $env:HOMEDRIVE+”\windows.old”
If(Test-Path -Path $path)
#create registry value
$regpath = “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations”
New-ItemProperty -Path $regpath -Name “StateFlags1221” -PropertyType DWORD -Value 2 -Force | Out-Null
#start clean application
cleanmgr /SAGERUN:1221
Write-Warning “There is no ‘Windows.old’ folder in system driver”
cmd /c pause


4 responses to “Windows.old is getting old…”

  1. Can you explain some of the logic to it and why 1221?
    I have been tempted many times just to delete Windows.old and the contents so I can regain space.

    1. Hi John. As I said, I borrowed the script, and while I guess I did once look at the details, I don’t remember what I learned. If you try to just delete the directory it will not work. You would have to use the CLEAN UP SYSTEM FILES, or this script to do it. You will get your space back though. Thanks for reading! -MDG

  2. Was about to write that one should use the “CLEANUP SYSTEM FILES” program to get rid of those folder(s)…..😉

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: