Free Disk space on Windows drive

 

Starting with Windows 2012 (R2), it is no longer necessary to install the desktop experience to remove the different file versions left update after update. The following command can be used:

<pre class="lang:batch decode:true " title="Regaining space on Windows System drive">dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase

Options used here are:

  • StartComponentCleanup: removes superseded and unused system files from a system
  • ResetBase: all superseded versions of every component in the component store is removed.

The resetbase can be quite interesting, On a 3+ years old Windows 2012R2 the lack of ResetBase allows to gain 4GB, its use averaged for 20GB free space.

To get a report view before doing anything damageable, you can run:

dism.exe /Online /Cleanup-Image /AnalyzeComponentStore

The command has been succesfully tested on Windows 2012R2 and Windows Server 2016.