Windows 10 – Remove Windows.old Folder


You can easily start this task within a command line, but since this does not solve the “problem”, I don’t provide this command. But I will provide a more useful information. You can use cleanmgr.exe, yes, this is the “Disk Cleanup” which is included since some versions of Windows:

But this is a GUI, how can we use this within in TS? I used my prefered search engine, and found a solution. You can create a Cleanup Profile, save this to registry, and then run the profile from command line. Seem cool? Here are the steps:
Go ahead, and start cleanmgr.exe with the following parameters:
cleanmgr.exe /sageset:1703

The parameter sageset instructs the cleanup wizard to save the selected options to the registry. The following number after the parameter sets the profile ID, or number, with which the settings are stored. The Number can be from 0 to 65535, so there might be enough numbering possible.

As soon as the wizard is loaded, you can select all the options you want to include within the cleanup, in my case, I only selected “Previous Windows Installation(s)” as shown in a print screen above. After a click on OK, the wizard writes this settings to the registry under “Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches”, per each setting:

As you can see on the previous picture, every setting from the wizard has a corresponding key within the registry. So if you have selected “Previous Windows Installation(s)”, you will find a new entry under “Previous Installations”, in my case named “StateFlags1703”, where the number from the parameter is represented:

Now you can export this, and import it within the Task Sequence, oder just write it through Powershell with the following command:
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations\" -Name "StateFlags1703" -Type DWORD -Value 2

When this is done, you only need to call cleanmgr.exe with the “sagerun” parameter, and the not (?) documented silent parameter:
cleanmgr.exe /sagerun:1703 /S
Without the /S parameter, the GUI will show up and requires you to press OK, what will not work within a TS.

Hope this helps, and deleting the windows.old folder, I still recommend to do only if required, otherwise let the scheduled task do the magic.

One thought on “Windows 10 – Remove Windows.old Folder

Leave a Reply


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

Google photo


Twitter picture


Facebook photo


Connecting to %s
