Scott Hanselman

Guide to Freeing up Disk Space under Windows 7

November 26, '11 Comments [50] Posted in Tools
Sponsored By

This is an "updated for Windows 7" version of my popular original article Guide to Freeing up Disk Space under Windows Vista.

I've got a 256 gig C: drive, but noticed that in the last week or so I'd had only 20 gigs free. Not cool and it was getting tight. A few hours later, I have 91G free. Here's how.

Warranty: There is none. Please read carefully and with all things you find on a random blog, be careful because you have no one to blame but yourself. However, if you take a few minutes, read carefully and do even a few of these tips or just run Disk Cleanup, you'll get lots of space back.

  • Win 7 SP1 Disk Cleanup - removing Service Pack Backup Files Clean up after Windows 7 SP1 (Service Pack 1) - After you install Windows 7 SP1, it leaves around the original files so you can uninstall the Service Pack if you want. After a few months with the Service Pack, I've decided for myself that it's a good thing and decided I don't need the option. In Vista there was a command line tool called "vsp1cln.exe" but in Windows 7 you can run Disk Cleanup and check "Service Pack Backup Files" and get back almost a gig of space.
    The only thing, again is that you can't uninstall SP1. Fine with me.
  • Disk Cleanup - It's amazing to me the number of people who DON'T run Disk Cleanup. It's even better in Windows 7. Just run it. Often. After you run it, run it again and click Clean Up System Files to get files that you need to be admin to delete.
  • Disable Hibernate - I have a desktop, and I prefer just three power states, sleeping, on or off. I don't use Hibernate. Plus, I have 12 gigs of RAM, and hibernation uses as much disk space as you have RAM. From an administrative command prompt, type "powercfg -h off" to get that space back. Got me back 12 gigs. It's up to you. Don't turn it off if you use the feature.
  • %TEMP% Files - Even though Disk Cleanup is great, sometimes for whatever reason it doesn't always get stuff out of the TEMP folder. I recommend you try to delete the TEMP folder. I do this from the command line. Open up an administrative console, type "cd /d %TEMP%" (without the quotes, of course). Then, go up one folder with "cd .." and type "rd /s temp"
    Do be warned, this command says to TRY to delete the whole folder and everything underneath it. It's very unambiguous. If you don't feel comfortable, don't do it. If you feel in over your head, don't do it. If it screws up your computer, don't email me. Next, I do a "dir temp" to see if the folder really got deleted. It usually doesn't because almost always some other program has a temp file open and the command can't get remove everything. If it DOES remove the folder, just "md temp" to get it back fresh and empty. This got me back 12 gigs. I'm sure you'll be surprised and get lots back.
  • Delete your Browser Cache - Whether you use Chrome, IE9 or Firefox, your browser is saving probably a gig or more of temporary files. Consider clearing it out manually (or use the CCleaner mentioned below) occasionally or move the cache from your browser's settings to another drive with more space.
  • System Protection for Local Disk Clean up System Restore - Windows 7 keeps backups of lots of system files every time something major (driver installation, some software installations, etc) happens, and after a while this can take up lots of space. It uses a service/subsystem called ShadowCopies and can be administered with a tool called vssadmin.
    Now, the EASIEST way to handle this is just to run Disk Cleanup, then click More Options and "Clean up…" which will delete all but the most recent System Restore data. That's what I did. That got me back lots of space back on my C: drive.
    You can also go to System Properties, then System Protection, then Configure and not only control how much space to allow for System Protection but also delete preview restore points as seen in the screenshot at left.
    Alternatively, you can use the vssadmin tool from an admin command prompt to to do important things. One, you can set a max size for the System Restore to get. Two, you can set an alternative drive. For example, you could have the D: drive be responsible for System Restore for the C: drive.
    You can use the commands like this. Note that you can put whatever drive letters you have in there. I ran it for each of my three drives. Note that this isn't just used for System Restore, it's also used for the "Previous Versions" feature of Windows that keeps some number of Shadow Backups in case you delete something and didn't mean it. Kind of a mini, local time machine. Point is, this isn't a feature you probably want off, just one you want kept to a max.
    Here's the command line I used. Your mileage may vary.
    vssadmin Resize ShadowStorage /On=C: /For=C: /MaxSize=15GB
  • SpaceSniffer 1.1.0.0 - www.uderzo.it Understand what's taking up all that space with SpaceSniffer or WinDirStat - I've used a large number of Windows Folder Size checkers, and the one I keep coming back to is WinDirStat. WinDirStat is actively developed, it's Open Source, and it works great in Windows. It's wonderfully multi-threaded and is generally fabulous. It'll help you find those crazy large log files you've forgotten about deep in %APPDATA%. It saved me 10 gigs of random goo. SpaceSniffer is also amazing and really lets you drill into what's going on space-wise in your disk.
  • Remove Old Stuff - Just go into Add/Remove Programs or Programs and Features and tidy up. There's likely a pile of old crap in there that's taking up space. I removed some Games and Game Demos and got back 5 gigs.
  • Uninstall anything evil - If you want to get a quick look at what's on a machine and uninstall LOTS of stuff quickly, look no further than NirSoft's My Uninstaller (download). Remove Toolbars (they think they need them and they never do and won't miss them), and anything that looks like it might destabilize their system. I check out toolbars, add-ins, etc
  • Wasteful TempFiles/ScratchFiles Settings in Popular Programs - Most programs that need scratch space have a way to set a ceiling on that Max Space. Go into Internet Explorer or Firefox, into the options and delete the Temporary Internet Files. Set a reasonable size like 250 megs or 500 megs. I've seen those cache sizes set to gigs. If you've got a speedy connection to the internet, that's just overkill. Check other programs like Adobe Photoshop and other editors and see where they store their temporary files and how large they've become. I used SpaceSniffer (mentioned above) and was shocked to find 5 gigs of old temp files from a year ago in little used programs.
  • A nicely compressed directoryNTFS Compression - That's right, baby, Stacker (kidding). This is a great feature of NTFS that more people should use. If you've got a bunch of folders with old crap in them, but you don't want to delete them, compress. If you've got a folder that fills up with text files or other easily compressed and frequently access stuff, compress 'em. I typically compress any and all folders that are infrequently accessed, but I'm not ready to toss. That is about 30-40% of my hard drive. Why bother to compress when Disk Space is so cheap? Well, C: drive space usually isn't. I've got an SSD, and it's small. I'd like to get as much out of it as I can without the hassle of moving my Program Files to D:. More importantly, Why the heck not? Why shouldn't I compress? It's utterly painless. Just right click a folder, hit Properties, then Advanced, then Compress. Then forget about it. As long as you're not compressing a bunch of ZIP files (won't do much) then you're all set. You might consider defragging when you're done, just to tidy up if you don't have an SSD.
  • Find Fat Temp File Apps and squash them - Google Earth and Microsoft Virtual Earth 3D are really fast and loose with the disk space. You can poke around for a while and next thing you know you're down 2 gigs or more. If you don't use the app a lot, delete the caches when you exit, or better yet, make the cache size for each app small.
  • Remove Crap with CrapCleaner (CLeaner) - This is a brilliant utility that removes crapware, unneeded programs, toolbars and other things that might litter up your machine.
  • works-on-my-machine-starburst ADVANCED: Use Junction Points/Hard Links/Reparse Points to move temp file folders - This is an advanced technique. If this technique kills your beloved pet cat, don't email me. You have been warned. Also, note that I'm only saying it works for me.
    I reclaimed 25 gigs just today by moving the MobileSync Backup folder from iTunes to a spinning rust disk off my SSD.
    Here's the idea. You'll move it to a drive with more space, but you'll LIE to iTunes using a little-used Windows Utility that will make a LINK between the folder iTunes expects to find and the folder you want your backups in. See? It's advanced but VERY powerful, especially when you
    C:\Users\Scott\AppData\Roaming\Apple Computer\MobileSync>dir

    Directory of C:\Users\Scott\AppData\Roaming\Apple Computer\MobileSync

    11/25/2011 10:10 PM <DIR> .
    11/25/2011 10:10 PM <DIR> ..
    11/25/2011 10:10 PM <JUNCTION> Backup [f:\iTunesMobileSync\Backup]
    0 File(s) 0 bytes
    3 Dir(s) 97,594,851,328 bytes free

While your are in there, why not do some more maintenance on your machine, blow out that dust and install some updates? Check out the The Technical Friend's Essential Maintenance Checklist for Non-Technical Friend's Windows Computer.

Hope this helps!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Saturday, November 26, 2011 7:27:05 AM UTC
Hey Scott, really nice tips.

WinDirStat in particular, is great.

Thanks!
Saturday, November 26, 2011 8:14:50 AM UTC
Man, the day you get a solution to clean the winsxs directory, you'll get surely the peace nobel prize
Amnesia
Saturday, November 26, 2011 8:24:30 AM UTC
I am quite anal when it comes to cleaning up disk space as I run a lot of virtual environments on very expensive and limited SSD drives. I can't wait for the Data Deduplication feature that ships with the next version of Windows Server.

CCleaner does do a pretty good job and takes care of most of the points in your post. It also gets rid of many other space hogs such as IIS log files, which tend to grow a lot if you are doing a lot of development.

I recently found out that it is safe to delete C:\Windows\Installer\$PatchCache$, which in my case freed up another 3.5GB of space.
Saturday, November 26, 2011 8:41:07 AM UTC

great article. these days it's not as big an issue because machines have so much space. but this kind of cleanup can make a huge difference when maintaining several virtual machines. i regularly clean and compact which can save 2-3GB at a time.
CCleaner does a great job on lots of known apps like the various browsers, cleaning up cache and compacting their internal databases. you can add custom paths or files too, so I usually add my user profile %temp% path as you mention, %userprofile%\AppData\Local\Temp\.
another area that does not get cleaned up is the windows update downloads. I add this path to CCleaner as well:
%windir%\SoftwareDistribution\Download\
if you run live mesh, those logs can get out of hand as well:
%userprofile%\AppData\Local\Microsoft\Windows Live Mesh\
and the google updater keeps a lot of stuff around, worth a look:
%userprofile%\AppData\Local\Google\Update\Download\
Google updated doesn't seem to clean up older versions, like with chrome. maybe it keeps one version back in case of rollback... but this can quickly add up to several hundred MB on top of your cache:
%userprofile%\AppData\Local\Google\Chrome\Application
jim novak
Saturday, November 26, 2011 11:11:39 AM UTC
Hi Scott,
Another great article, thanks !
Did you know that HDGraph 1.4 can be sometimes a great (WPF) alternative of WinDirStat ?
Saturday, November 26, 2011 1:04:43 PM UTC
Folder size win32 is a great small no dependency program for visually see whats taking space.
Mattias Karlsson
Saturday, November 26, 2011 1:19:55 PM UTC
Use pnputil to remove older and superseded drivers from the driverstore under C:\Windows\System32. This saves a lot of space. Also uninstall older updates like older and replace IE updates.
Saturday, November 26, 2011 2:27:23 PM UTC
Just a couple of notes. If you've got UAC enabled then you need to start Disk Cleanup in administrator mode, otherwise the "More Options" tab isn't there. Just hit your Windows key, type in "disk", find the entry, right click, and choose "Run as administrator". Also you should open up your command prompt for any commands in administrator mode as well.
Saturday, November 26, 2011 3:37:59 PM UTC
For the %TEMP% removal, you can simplify it by cd %temp% and then 'rd /s /q .' - that will still try to remove everything in the directory, but you can skip the 'cd ..' and because your cmd, it guarantees that something has the directory open, so you don't have to then mkdir afterwards.

It also works even if your %temp% folder doesn't have 'temp' as the actual directory name. :)
Saturday, November 26, 2011 3:42:04 PM UTC
Another tip that's not on the list, but is quite the disk space saver is the following. Similar to how Windows uses the same amount of HDD space as your RAM for hibernation it does the same for the swap/page file (pagefile.sys). In my case I have 16gb of ram on my laptop, so I had a 16gb swap/page file, which is a complete waste. This can be changed in Control Panel -> System -> Advanced System Preferences -> Advances -> Performance section Settings button -> Advanced -> Virtual Memory section Change -> untick "automatically manage" and set it to "Custom Size" something like 1GB if you have lots of RAM. On next boot the pagefile.sys will be 1GB instead of e.g. 16GB.
Saturday, November 26, 2011 4:48:48 PM UTC
I'm fond of Disk Space Fan - not open source, but has a free version and looks pretty.

Windows is very bad at using disk space wisely. What is safe to delete (and the safe way to delete it) is confusing enough for geeks - there is no way I'd recommend this to the average user. I think Microsoft assumed we'd all be on multi-terabyte drives now and didn't see the rise of SSDs coming.

I hope Microsoft has spent major effort fixing this in Win 8 - I don't want to be deleting restore points and temp folders when my 16 GB tablet says it has no room left for an ebook!
Saturday, November 26, 2011 7:53:45 PM UTC
Moving the virtualy memory to a larger volume/partition can help a lot too. For example I have 12G RAM, so the pagefile.sys file would eat a really large piece from my SSD. The other thing was hiberfil.sys, but that is mentioned in the post.
Tom
Saturday, November 26, 2011 9:23:48 PM UTC
Please note, the following should definitely be considered to have Scott's "Work's on my computer" disclaimer applied to it.

SingularLabs has made a nice little add-on (INI File) for CCleaner which adds some additional things that CCleaner can remove from your system. Some of these are great and include things I've always wished the original CCleaner had.

You can grab the tool here: http://thewebatom.net/software/ccenhancer/

Again, keep in mind that some of these are fairly hardcore (? not sure if that's really the word I want... :D) and so use them at your own risk. You could easily end up remove some files/settings you didn't mean to if you aren't careful.

As long as you pay attention you should be able to get CCleaner to remove even more of the junk you didn't want hanging around.

It's also nice to see how the additional definitions are added so you can add your own later if you are a super-geek power user. ;)
Sunday, November 27, 2011 1:26:51 AM UTC
I recommend TreeSize. Been using it for ages to visually track my hard disk space
http://www.jam-software.com/freeware/
Sunday, November 27, 2011 7:19:33 AM UTC
While I'm as much of a fan of WinDirStat as you are, I think your comment that it's actively developed is a bit inaccurate, as the last available file on sourceforge is dated 2007!
Sunday, November 27, 2011 10:50:54 PM UTC
You are writing about precious SSD C: drive and later that it is good to defrag just to tidy up.. Well, defragmentation is pointless with SSD and makes SSD life shorter :<
paul
Sunday, November 27, 2011 11:56:05 PM UTC
I've just run the Desktop Cleanup and what a difference: 1.5GB and I thought I ran a clean system!

Just an aside, relating to your MKLINK usage: I used this to fool an implementation of Pervasive DB to install on a 64-bit platform by faking out the location of "Program Files\Pervasive" and it worked like a charm. MKLINK is really useful if you know about it.
Monday, November 28, 2011 7:59:22 AM UTC
Instead of cleaning up the %TEMP% folder every once in a while, I configured a little shutdown-script which will clean out the temp folder.
Monday, November 28, 2011 10:47:30 AM UTC
Listened-to podcasts in iTunes can take up loads of space.
Monday, November 28, 2011 12:48:51 PM UTC
I second the suggestion for TreeSize Free edition. I install it every time. It's essential for SEEING where your disk space is being used.
Monday, November 28, 2011 2:45:02 PM UTC
Recently my small 128GB SSD main drive was pretty full despite my effort to discard unused stuff, and CCleaner freed 17GB in just a few seconds, without any 'bad surprise' so far. My understanding was that it removed mainly old unused MSI mess (>10GB!) and App cached data, like GoogleEarth or browsers cache.

Your advices are especially useful nowadays, when developers are using small but fast SSD drives. Thanks
Tuesday, November 29, 2011 2:33:15 AM UTC
Knew most of these but the hard links/junction points is interesting. Could that be used to install visual studio on a different drive? Usually even if you install visual studio to a different drive the majority of it is still installed on C as far as I have ever worked out.
Tuesday, November 29, 2011 12:18:01 PM UTC
Hi!

Great article! But what about the "MobileSync" stuff at the bottom? Probably stuff from the previous article? :-P
Mike
Tuesday, November 29, 2011 12:28:18 PM UTC
"You have been warning." I can't stop laughing!

Besides that, great tips.
Obi
Tuesday, November 29, 2011 8:19:17 PM UTC
Another trick I use for keeping my disk tidying is moving temp folders to a ramdisk (currently using Dataram's RAMDisk: http://memory.dataram.com/products-and-services/software/ramdisk). I have web browser temp folders, ProjectAssemblies, ReflectedSchemas, ReflectedTypeLibs, Temporary ASP.NET Files, etc. pointed over there. Most are pointed using junctions if the applications don't support pointing to other folders natively.

This way, reboot -> clean slate.
timb
Wednesday, November 30, 2011 7:38:13 AM UTC
Hey scott, very nice post, as usual.
I have one question though. A couple of weeks ago, I went meticulously over my hard drive and was able to "blue" up all my partitions (I freed about 40gig in my 320gig HDD). This is great, but using WinDirStat on my C: drive, I found a folder that's taking more than 15gig of space! it's "c:\windows\installer". I know that not ALL of that is necessary, but I couldn't find a way to reduce its size. Any idea about that?!
Wednesday, November 30, 2011 1:13:38 PM UTC
Just running disk a basic clean up recovered 43 Gigs for me due to an insane amount of Temporary Files. Time to find out what application isn't cleaning up after itself I think!
Thursday, December 01, 2011 11:08:43 PM UTC
+1 to CCEnhancer for CCleaner - I recently had to do the same exercise on my laptop to try and regain some space on my system drive.

I had a bunch of files I didn't use very often in my docs so decided to compress them with WinRar - this freed up tons of space - I guess achieving similar results to NTFS compression?

Another tool that was mentioned above is DiskSpaceFan - I really like the way this visualises the space taken by folders/files.
Wednesday, December 28, 2011 6:44:11 PM UTC
This freed up ~3.5 GB from my SSD running windows 7 pro x64 sp1:

1. Run CMD with elevated priv.
2. Write: dism /online /cleanup-image /spsuperseded

It cleans up backup files from service pack installation.

/Michael

Tuesday, March 27, 2012 9:57:43 AM UTC
Hello Friend!!!

I had followed according to assumption to remove unnecessary data or file but still my computer is increase slightly so that please any one tell me that should i use disk utility software for ease of speed problem....
Monday, August 20, 2012 4:03:13 AM UTC
Awesome guide.

Saved me a heap of Gigs on my SSD.

Also learned that CCleaner means Crap Cleaner, thought it meant the C: drive. :p
Miks
Friday, September 28, 2012 12:38:01 AM UTC
Brillant tutorial!!! Thanks.
Mau
Friday, October 12, 2012 6:16:13 PM UTC
Very good article. Tools which you suggested helped to find out a 54GB SQL errorlog file!!!

In order to clear the logs plz refer:

http://support.automation.siemens.com/WW/llisapi.dll?func=cslib.csinfo&objId=34391937&nodeid0=10806914&nav0=tree&load=content&lang=en&siteid=cseus&aktprim=0&objaction=csview&extranet=standard&viewreg=WW
Aji
Friday, October 26, 2012 12:11:19 PM UTC
Excellent article...slimmed down another 40GB, now ready for my SSD upgrade! Many thanks!
OddyOh
Tuesday, October 30, 2012 2:28:58 AM UTC
Thank you so much for your great tips.
Thursday, November 08, 2012 7:06:06 AM UTC
Thanks a lot i am using both CCleaner and Soft Cleaner.
Ranji
Thursday, December 06, 2012 3:17:26 PM UTC
I was thinking a lot about the "why not?" message in the NTFS compression point, so I took to a search engine and started looking around.

Best practices for NTFS compression in Windows

In that article it specifies that NTFS compression does not save on network bandwidth, and that copying files between folders will expand the files before copying. This seems rather wasteful, and I noticed the article was last reviewed in 2009. Has Windows 7 moved on from this obvious oversight and implemented a copy-compressed-file system when copying files?
David Wood
Wednesday, December 19, 2012 9:02:13 PM UTC
Clean up System Restore tip was money! Got back 9 GB right there alone. Thanks!
Don
Sunday, January 27, 2013 11:24:31 AM UTC
Some useful tip here, especially about using WinDirStat to see how the hard disk is being used.

What I don't understand is: How is it that the Windows 7 software package, that is supplied on a 4.7GB DVD, and "Only" needs 16GB available hard disk space, can morph into a monster that now occupies 51GB on my hard disk.
http://windows.microsoft.com/systemrequirements
Paul
Sunday, January 27, 2013 11:26:23 AM UTC
I forgot to say that I keep all my software and user on separate D: and E: partitions
Paul
Monday, February 04, 2013 6:36:59 AM UTC
Can anyone tell how to get rid of my problem??????
I am using Windows 7, My Temp folder(C:users\...\AppData\Local\Temp)is eating up all hard drive space about 60 GB.
Many times I deleted the contents from Temp folder but as soon as I connect to the internet "Temp" folder is started stuffing with fixed sized 15,171 KB files(cac3B4F.tmp, cac1F92.tmp, cac1F93.tmp....cacFEB4.tmp), and with 2 hours I start getting message to free up some space on C drive.
Please tell me how to deal with it.
Thanks
Ejaz
Friday, February 22, 2013 3:17:32 AM UTC
I need to have my lap-top cleaned and make it faster I do not think I have the space for everything I have down loaded and I,am pretty sure a hacker has been in my documents, I would deeply appreciate your help.
Friday, February 22, 2013 3:26:24 AM UTC
THANKS FOR THE TIP IT WORKED WONDERS, THANK YOU, J.T
Sunday, February 24, 2013 3:46:05 PM UTC
I have Windows 7 64 bit and would like to know is there anyway I can remove the Windows updates that were install in 2012. If so how, please provide detailed steps. thanks.
Victor
Wednesday, March 13, 2013 2:48:04 AM UTC
Some great tips! Went from having 27GB in Windows folder now down to 17GB plus removed another 5GB from hibernation file. Happy days!
Max
Tuesday, March 26, 2013 5:40:48 PM UTC
Great article! Just removed 7 Gigs of useless data from my C:
Thank you.
Embok Ramde
Tuesday, March 26, 2013 7:44:38 PM UTC
Why? Why should I do this? Why do I need to take all these steps at my mother in laws pc every year? Yes windows is better now, it used to be every month a day of pain getting rid of browser bars that fill half the screen, tray icons and worse. IMHO for consumer stuff I do not want to be bothered, the OS should behave sensible mother in law proof.

Note my mother in law once deleted the win32 dir... I convinced her to really read all the details of the winxp license when reinstalling...

For virtual machine images, databases and other special thing I am willing to read documentation.

Side note:
I learned the hard way, it is not a good idea to compress C:\ containing sql server files.
Wednesday, March 27, 2013 10:41:21 PM UTC
I love FolderSizes:

http://www.foldersizes.com
Duder
Tuesday, April 02, 2013 5:13:47 PM UTC
I just installed CCleaner using the "express" option, and got a bunch of malware for my trouble (mixi dj toolbar and some other browser addons). This is not really the direction I wanted to go ...
Tara
Saturday, April 06, 2013 7:03:35 PM UTC
Just followed your tips and got 32% of my C drive back. Thanks a 1000%

Majik WiZz
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.