How To: Delete windows.old from Windows Server 2012 R2

I’ve been updating my various environments from Windows Server 2012 RTM or Preview releases (build 9431) of Windows Server 2012 R2 to the final bits. On some boxes I just use my scortched earth policy of leveling the partitions and starting from scratch – others I will do an install and use the same partition. You get the following dreaded message – which you dismiss and move on.


Sure – I’ll just go and delete that directory after a while and go about my merry way.

Unfortunately it is not that easy.

In Windows client environments, you can just kick off a “disk cleanup” routine and have it removed – saving you a dozen or more GB of space. Unfortunately, that Disk Cleanup does not exist in Windows Server 2012 / 2012 R2 Full GUI install, unless you add Desktop Experience.


Fear not. Once you have confirmed you need nothing from that old c:windows.old directory structure, you can manually delete it, with a little bit of extra effort.

Here’s how you do it.

1) Download Junction.EXE from Sysinternals. I extracted and saved it to c:source. You will use this tool to generate a list of all the junctions that have to be removed.

2) create a reference file that lists all the junction points and symbolic links in use by opening up a command prompt, changing into C:source and running

junction.exe –s –q c:windows.old >junctions.txt

3) open up PowerShell ISE administrator rights and run the following script to remove all symbolic links and junction points in c:windows.old.

foreach ($line in [System.IO.File]::ReadLines(“c:sourcejunctions.txt”))
if ($line -match “^\\”)
$file = $line -replace “(: JUNCTION)|(: SYMBOLIC LINK)”,””
& c:sourcejunction.exe -d “$file”

You should get the following scrolling by…


Now it’s some simple taking of ownership, granting rights and deleting windows.old to get your space back.

4) to take ownership use

takeown /F C:windows.old /R /D Y

5) delete c:windows.old – you now have permissions and ownership.

How much space you get back will change based on your particular situation.  My last run at this saved me 15.5 GB of space on my OS drive.

Note: Kudos to Peter Hahndorf’s response on on which this article was based.

About author View all posts


3 CommentsLeave a comment

  • I noticed in Windows Server 2012 R2 at least – there also is a disk cleanup option now if you choose the “cleanup system files” option for “Previous Windows installation(s)”.

    • That option is not available in WS2012R2 unless you have desktop experience installed. It’s a client functionality.

  • Hi, I have a little doubt, is there any difference between:

    junction.exe –s –q c:windows.old >junctions.txt


    dir /AL /B /S c:windows.old>reparsePoints.txt

    I would then remove the reparse points with “fsutil reparsepoint delete” inside a FOR cicle.

    Regards, Francesco Papini

Warning: sizeof(): Parameter must be an array or an object that implements Countable in D:\home\site\wwwroot\wp-content\plugins\projectnami-blob-cache\project-nami-blob-cache.php on line 416

Fatal error: Uncaught WindowsAzure\Common\ServiceException: Fail: Code: 400 Value: The account being accessed does not support http. details (if any): <?xml version="1.0" encoding="utf-8"?><Error><Code>AccountRequiresHttps</Code><Message>The account being accessed does not support http. RequestId:7590ca59-401e-0014-0c80-f20b2b000000 Time:2021-01-24T18:42:50.7704621Z</Message><AccountName>ritgcache</AccountName></Error>. in D:\home\site\wwwroot\wp-content\plugins\projectnami-blob-cache\library\WindowsAzure\Common\Internal\Http\HttpClient.php:382 Stack trace: #0 D:\home\site\wwwroot\wp-content\plugins\projectnami-blob-cache\library\WindowsAzure\Common\Internal\Http\HttpClient.php(275): WindowsAzure\Common\Internal\Http\HttpClient::throwIfError(400, 'The account bei...', '\xEF\xBB\xBF<?xml versio...', Array) #1 D:\home\site\wwwroot\wp-content\plugins\projectnami-blob-cache\library\WindowsAzure\Common\Internal\RestProxy.php(141): WindowsAzure\Common\Internal\Http\HttpClient->send(Array, Object(WindowsAzure\Common\Internal\ in D:\home\site\wwwroot\wp-content\plugins\projectnami-blob-cache\library\WindowsAzure\Common\Internal\Http\HttpClient.php on line 382