How can I automate removal of Windows.old after a Windows 25H2 upgrade?

September 2, 2026 4 answers
Asked by MapleOrbit42
I need to reclaim disk space on hundreds of systems that were recently upgraded to Windows 25H2. Cleanmgr can remove the previous installation interactively, but I haven't found a reliable way to automate that cleanup. I also tried combining DISM, takeown, icacls, and Remove-Item, but junction loops caused errors and prevented the directory from being removed. What is the safest way to perform this remotely without logging into each machine?

Answers

OrbitingFox23
Storage Sense policies are another option if you already manage them centrally. Configure the policy to remove previous Windows installations and let the devices process it on their normal maintenance schedule. The `/autoclean` switch is sometimes suggested, but it may not work consistently for this scenario.
Reply to this answer
VelvetKite88
Cleanmgr can be scripted through its registry-backed presets. On a test machine, run `cleanmgr /sageset:777`, select Previous Windows installation(s), and save the settings. Then deploy the corresponding StateFlags777 registry value under `HKLMSOFTWAREMicrosoftWindowsCurrentVersionExplorerVolumeCachesPrevious Installations` and run `cleanmgr /sagerun:777` with administrative privileges.

CedarBlink5: Thatโ€™s probably the route Iโ€™ll use if the installation cleanup doesnโ€™t happen automatically after the rollback window expires.

Reply to this answer
SilverNoodle31
Windows normally removes the previous installation automatically once the rollback period ends, which is commonly around 10 days, though the exact timing can vary. If you need the space sooner, use a Storage Sense policy or the scripted cleanmgr preset rather than manually deleting the folder.

AmberPiano64: Iโ€™ve seen it take closer to 10 days in practice, so I wouldnโ€™t rely on the automatic cleanup if disk space is urgent.

Reply to this answer
QuietHarbor7
Avoid taking ownership and manually deleting Windows.old. Junctions and protected system folders can cause the process to follow paths it shouldnโ€™t, and changing permissions may damage ownership or ACLs on other parts of the system. Test any cleanup method on a small pilot group first.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions