Reply To: Delete' Windows.old' folder using powershell

  • Topaz George

    Organizer
    21 July 2020 at 8:21 pm

    Hope this helps.

    If(Test-Path -Path($((Get-WmiObject Win32_OperatingSystem).SystemDrive) +"\windows.old"))
    { 
    	New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations" -Name "StateFlags1221" -PropertyType DWORD  -Value 2 -Force | Out-Null 
    	cleanmgr /SAGERUN:1221 
    }