cloud.net

Thursday, April 2, 2009

Moving your Windows Installer Directory

I mostly work with Virtual Machines and I like to pre-allocating the disk size. When I created my VM I figured 10GB would be enough for C:\ with Win2003 Server and a couple of SDK's and if I needed more I could always add another drive. I was wrong.

After 2 years my faithful Win2003 dev VM is out of space on C: and I can't shuffle any more files around.

My C:\windows\installer directory is >2GB so this is my prime candidate to move. Luckily there are always solutions to problems... no I'm not going to delete the directory, or change my registry to point to a new location.
I'm going to add a symbolic link from C:\windows\installer to F:\installer.
  1. Download Junction from http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx
  2. Copy OR move C:\windows\installer to F:\installer
  3. Delete all the files in C:\windows\installer
  4. Close all your Explorer windows
  5. Run > cmd> C:\junction C:\WINDOWS\Installer F:\installer
That should do it. I wrote a batch (run.bat) script to do the whole procedure.
@set src=C:\WINDOWS\Installer
@set trg=F:\Installer
::copy %src%\* %trg%
::detele %src%\*
move /y %src%\* %trg%
junction %src% %trg%
pause
This should work for most directories. The batch file should be in the same directory as junction.exe.

18 comments:

Giovanni said...

Thanks a lot!!! This is a hidden gem!

Giovanni said...

I've noticed the following post... http://forums.techarena.in/customize-xp/992648.htm . Do you have any comment on that?
Thanks again!

rayone said...

Giovanni... my understanding was they didn't work well on removable disks.

Maybe if he enables write caching for the disk it would help... just a guess though.

MS Installer wouldn't know it's a symbolic link.

If u have a EEE PC the best performance I've got with SSD is using C: FAT32 for all windows + page file, then D: all programs/profiles.

Anonymous said...

futu-ti mortii matii de cretin cu tampenia ta cu tot

Unknown said...

Thanks a lot too!!! you saved my day, I assigned also 10gb for a windows 2003 c: drive, and I was in trouble now...

Thanks again!

Anonymous said...

I try this tip, but it takes the same space in drive C:. Then, there is no more free space on drive C:...

Sundown said...

Thank you, this worked beautifully to free up 11Gb of my 64Gb SSD c: drive! On Win7 I also had to delete the c:\windows\installer folder after emptying it

touille said...

Thanks a lot ! good to know that we can do symlink on windows system.

Unknown said...

Thanks :) Been looking for a solution to this. Small SSD disk, and large non-ssd disk on this system with large programs installed was moving towards beeing a problem because of the installer dir.

Anonymous said...

your sample batch file has delete transposed.

me2olive said...

Great tip, thanks!

Thierry said...

Using this trick which look nice make me lost all the content of my windows installer folder !

It first look to work well but when you reboot the folder on the new drive is empty and a new empty Installer folder exists on the drive c

have a look on http://forum.sysinternals.com/problems-with-junction_topic16205.html

rayone said...

@Thierry

1.- You're copying/moving the contents, so you should always have 1 copy.
2.- This seems to be a rare issue where the link isn't created properly... possibly because it was been written to.
3.- If you're new folder is empty, you didn't copy/move the contents, or there's something else wrong.
4.- You should still be able to recover the lost data with an undelete app.
5.- This technique works, you must have introduced an new variable.

Regards, Ray.

Brad said...

Thanks for this. I've had to use it on two of my own and three client servers so far. Dell ships their servers with a default 12GB C:\ and after 3-5 years that fills up quickly.

I use symlinks all the time in Linux but was unaware until now that this was possible with Windows. Thanks again!

Unknown said...

Thanks a lot! this is brillaint

Edvardsen said...

Thank you very much for your script and for sharing your knowledge :)

I used the junction program without using your bat-file.

I found it strange at first that I didn't find the Installer-folder inside windows folder...

Anyway, I wrote the path manually in windows explorer and selected all files and copied it over to the second drive.

-at a later point in the process I checked out the folder settings for C:\WINDOWS\ and I had of course the windows setting to hide protected operating system files enabled. I disabled this and then it was of course easier to find the Installer-folder :)

I nearly deleted a hidden folder ($PatchCache$) inside C:\WINDOWS\Installer but I moved it over to the second drive afterwards so I believe it went OK.

After I was finished with the process of moving everything inside Installer folder, I executed junction with the source and dest-folder (as described in your ordered list).

And to my clearification point:
I first got an error message, somthing about it coudn't create a folder that already existed. Enough info to get the point. I tried then to delete the source folder, C:\WINDOWS\Installer and not just all the files inside that folder.

Wouala. Now everething went fine :)

So Thanks again helping me clear some valueble disk-space!

Know to my question:

Anyone knows if it is possible to use this on C:\Program Files\Common Files\

?
Best Regards M Edvardsen

rayone said...

Glad it helped... if you're using Vista-Win8 you may want to look in to compressing your WinSxS folder too ;)

navhaxs said...

thanks, moved 3.7GB off my ssd