RSS

Windows 7 Move the Users and Program Files Directories To A Different Partition

Wed, Aug 5, 2009

Misc

  1. After installing windows 7 you will be greeted with a user creation prompt press shift+f10 and you should get a cmd window up like in the image belowcmduser
  2. Copy the Users Profiles, Program Files And ProgramData Folders onto the Partition you want to use
    robocopy "C:\Users" "D:\Users" /E /COPYALL /XJ
    robocopy "C:\Program Files" "D:\Program Files" /E /COPYALL /XJ
    robocopy "C:\ProgramData" "D:\ProgramData" /E /COPYALL /XJ
  3. Delete the old folders and create links
    For Program Files:

    rmdir "C:\Program Files" /S /Q
    mklink /J "C:\Program Files" "D:\Program Files"

    For the User Profiles:

    rmdir "C:\users" /S /Q
    mklink /J "C:\users" "D:\users"

    and lastly ProgramData:

    rmdir "C:\ProgramData" /S /Q
    mklink /J "C:\ProgramData "D:\ProgramData"

    If you have any permissions issues while deleting C:\ProgramData don't worry about them just try to delete it and make the links again after first reboot

  4. Now open regedit simply by typing regedit on the cmd window
  5. To change the program files path navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion and edit the ProgramFilesDir and CommonFilesDir as needed
    regeditproc
  6. For the user profiles you'll need to go to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList and again edit the paths as needed
    regeditprof
  7. Exit Regedit and the cmd window
  8. Continue to create your user
  9. Reboot your machine and you should be good to go
, , , , , ,

This post was written by:

Duffy - who has written 49 posts on Tuts4Tech.

I am the owner of this website, please feel free to ask me any questions you have

Contact the author

24 Responses to “Windows 7 Move the Users and Program Files Directories To A Different Partition”

  1. FuriousGeorge
    FuriousGeorge Says:

    This is the #1 result in google for the search query "windows 7 move programdata"

    Luckily for me I also want to move Users, and Program Files (and Program Files (x86) so I'm hoping this will work.

    Thanks for taking the time to make this public.

    Your method omits one important directory, however: winsxs. I've found a similar tutorial for moving winsxs in vista, and I think I'll try that after your tweak.

    http://aspoc.net/archives/2007/12/05/how-to-move-the-winsxs-directory-in-vista/

    With me luck!

    Thanks again.

  2. Duffy
    Duffy Says:

    Hi FuriousGeorge,
    Took a quick read over that method for the winsxs directory it should do the trick. I'm sorry the pictures for this post are currently missing, had a few server side issues which lead to the lost off all pictures/files and comments

    Regards,
    Duffy

  3. FuriousGeorge
    FuriousGeorge Says:

    It worked pretty well. I did get a BSOD after renaming/moving winsxs, rebooting, then booting into Linux to remove the old winsxs directory (b/c I couldn't in windows as promised in that link), then booting back into windows. Luckily that hasn't happened again.

    Also, I've noticed in the logs that I had an episode of 7 or 8 services failing and restarting.

    FInally, the main problem is that it breaks some WIndows Updates, for reasons described here: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.windowsupdate&tid=65695f88-726c-4194-8773-8c3b24dc4928&p=1

    In the past I've achieved this through registry hacks alone by copying C:\Users and C:\Program* to the new partitions, and editing the registry.

    The result was, after 6 months:

    C:\Users had grown to 4 or 5 gigs, mostly from temp data that had not been redirected in the registry hacks. After cleaning that out it is about 1.2 gigs.

    C:\Windows is 24 gigs, 13 gigs of that is in winsxs (I did not move it last time)

    C:\Program Files* have grown to 1.5 gigs from the .75 gigs or so they started at.

    Finally, c:\Program Data is .3 giga.

    My goal is to keep the primary partition small enough to fit on 35G SSD media.

    My point is that in the grand scheme of things, the better practice may be to use your method to relocate C:\ProgramData and C:\Users, use the similar but slightly more complicated method to move C:\Windows\winsxs and C:\Windows\SoftwareDistribution, and to leave C:\Program Files* where they are, while changing the default installation directory in the registry to D:\Program FIles*.

    Winsxs, as I udnerstand it, holds DLLs, so there may be some advantage if it can fit on the SSD, but I think I'd rather put MS Office there, and keep the Page and Swap files there.

  4. FuriousGeorge
    FuriousGeorge Says:

    Oh yeah, almost forgot: On 64-bit versions you have to make the same changes to:

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion

    ... and ...

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\WindowsNT\CurrentVersion\ProfileSet

    So I restarted the entire process, changing it as I described above (moving winsxs, but leaving C:\Program Files* while moving the default Program Files* directories to P:\).

    Looks like those same updates still fail.

    If they don't for you, then it must have something to do with my having moved winsxs. I tried moving Windows\SoftwareDistribution back, but it didn't help.

    Oh well.

    Next time I'll try doing the updates before I move winsxs, but after changing the registry values for ProgramFilesDir*

  5. Duffy
    Duffy Says:

    Hi FuriousGeorge,
    Does it not work if you just follow the instructions in the tutorial for moving C:\Users C:\Program Files and C:\ProgramData and then doing the following for winsxs

    robocopy "c:\windows\winsxs" "D:\winsxs" /E /COPYALL /XJ
    rmdir "c:\windows\winsxs" /S /Q
    mklink /J " c:\windows\winsxs" "D:\winsxs"

  6. FuriousGeorge
    FuriousGeorge Says:

    ... sorry, last point: a comment on the "How to move winsxs" link indicates it should break windows update.

    I moved it back and I was able to update.

    I am curious if you are also able to install all your updates with C:\Program Files as a junction.

  7. Nix
    Nix Says:

    Awesome tutorial.

    One thing I'll mention, I was browsing around and found a website that suggests using a hard link:

    "Use the /J switch to create a junction that’s a hard symlink. (If you use the /D switch, you’ll also have to edit the registry, cuz it won’t be a hard link.) Using /J, when Windows looks for the C:\Users dir, it will find it! But it will be on the HDD instead of the SSD. Tricky!"

    The website is http://www.tips5.com/how-to-relocate-user-profile-folder-to-other-drive-in-windows-7

    I just got my new hard drive, so I'll be fooling around with this and see how it works.

  8. Nix
    Nix Says:

    Whoops, I misread your commands, I thought you were using "/D" instead of "/J"

    In that case, I'll ask why do you edit the registry when you are creating a junction that points everything that looks for "C:\Program Files" to wherever you moved it?

  9. Duffy
    Duffy Says:

    Hi Nix,
    The registry tweaks are to set system variable correctly e.g %programfiles%

  10. Nix
    Nix Says:

    Interesting, it seems if editing the registry is _not_ done, then windows update will give a "80070011" error when trying to install some updates.

    Editing the registry as you mentioned above fixes this.

  11. RickyS
    RickyS Says:

    Hi there - this is a great thread - however, I am not getting this fully working:

    1. I couldn't delete my ProgramData as described above. Went on to edit the registry and delete the ProgramData after first reboot.. which is fine as this is noted above

    2. This is the issue - my user profile pictures have disappeared. Half my start menu items are no longer there e.g. cmd.exe - I have to search for cmd in accessories then I can open it. I can't search for it in the start menu (windows 7 x64). Also, I cannot access my computer properties (e.g. right click on my computer > manage)??

    3. I've noticed that there are 2 ProgramData files on my newly located D:\ drive. One is inaccessable. The other one is fine. My thinking is that this ProgramData file which cannot be accessed is the result of the robocopy detailed above. The second one which is being used is the result of changing the path in the registry..

    Can anyone help here please? Would really like this to work as I'm using SSD

    Cheers
    Rixx

  12. RickyS
    RickyS Says:

    ProgramData 'file' referenced above is meant to read 'ProgramData folder'

    Thanks

  13. Duffy
    Duffy Says:

    Hey RickyS,
    Could you give me the output of
    dir C: /A
    and
    dir D: /A

  14. FuriousGeorge
    FuriousGeorge Says:

    @Ricky

    #1 I couldn't delete it either. I could after changing the registry values and rebooting.

    #2 Did you manually make the ProgramData directory hidden, and allow those settings to be inherited by child items? That will make start menu items disappear. Just taking a stab in the dark.

    #3 How can there be two "ProgramData" directories unless they are spelled slightly differently?

  15. Clarinda Arnaud
    Clarinda Arnaud Says:

    Just desire to state your write-up is striking.The clarity inside your submit is merely striking and i can get for granted you're an professional on this topic.Properly with your permission permit me to grab your rss feed to keep up to date with forthcoming publish.Thanks a million and please maintain the nice job. Excuse my mediocre English. English is not really my native language.

  16. Daniel
    Daniel Says:

    Hey Furious George, you don't happen to be writing a guide for this just now, do you?

  17. Juan
    Juan Says:

    I installed windows 7 on my first primary partition three days ago. Then went through your instructions to move program files and programdata.
    1. Robocopied the folders to j:\Win7\ ... .
    2. Tried but was not able to delete old folders (access denied). Tried many times and then renamed them(adding an x before each name) in order to ...
    3. Did the mklinks.
    4. Modified the registry.
    5. Rebooted.
    6. Still could not remove the old folders (access denied). Tried a few times like:
    a. Login as system administraor.
    b. Inspected security and found the r attribute. Tried turning it off withour success.
    b. Restarted to Win XP (on my second primary partition) and tried everything again (access denied).
    d. Thus restarted back to the Windows 7 partition.
    7. Installed Office 2007 and verified that installation was properly done to the j:\Win7\Program Files directory.
    8. Upadated windows from internet.
    9. Displayed the c:\ partitioon (windows explorers) and it shows two Program Files one of them linked plus an extra xProgram Files. Under DOS, one of the Program Files has a long name including the fact that it is linked to the j:\win7\Program Files.
    10. The update seems to have created one additional Program Files and one additional Programdata on the c: partition.

    Thus, I restarted my second primary partitiona, Windows XP, and reformated the first primary partition with Power Quest Partition Magic 8, deleting all traces of the Win installation. The tried to remove the j:\Win7 folder and got the access denied error message again. Renamed the win7 folder to xxwin7 with no problem. Then restarted to my first primary partition, started a brand new Windows 7 installation. Everything went fine and stopped there. No additional installation. No windows update. No folder moving.

    Here I am now thinking of what to do next. I want to move those folders but I want to avoid the problems I had. Still, I have that xxwin7 folder on partition j;. I don't know what to do with it. Googled around for a while but must of the questions/answers are somewhat unresponsive or incomplete. From what I read here, it can be done. May be I have a particular problem which is absent in other cases.

    See my Windows 7 system information below:
    ========================================================================
    System Information report written at: 02/20/10 14:16:43 System Name: NET5
    [System Summary]

    System Information
    Item Value OS Name Microsoft Windows 7 Home Premium Version 6.1.7600 Build 7600 Other OS Description Not Available OS Manufacturer Microsoft Corporation System Name NET5 System Manufacturer Gigabyte Technology Co., Ltd. System Model G41M-ES2L System Type X86-based PC Processor Pentium(R) Dual-Core CPU E5200 @ 2.50GHz, 1700 Mhz, 2 Core(s), 2 Logical Processo r(s) BIOS Version/Date Award Software International, Inc. F6, 11/4/2009 SMBIOS Version 2.4 Windows Directory C:\Windows System Directory C:\Windows\system32 Boot Device \Device\HarddiskVolume1 Locale United States Hardware Abstraction Layer Version = "6.1.7600.16385" User Name Net5\Castro Time Zone SA Western Standard Time Installed Physical Memory (RAM) 2.00 GB Total Physical Memory 1.96 GB Available Physical Memory 1.32 GB Total Virtual Memory 3.93 GB Available Virtual Memory 3.23 GB Page File Space 1.96 GB Page File C:\pagefile.sys

    Can you help?

    Juan

  18. Joe
    Joe Says:

    I was try to play with the windows infrastructure and was curious if you had any knowledge on moving around the "Windows" system file folder on the installation. I've been doing it a similar way to your method but through booting into the installation disc and doing the commands there. I've changed a few references in the registry such as the winload.exe but i'm sure there's plenty more and i was curious if you knew of a place that had them listed or a way to do it in bulk. Thanks for your time, help, and great articles, keep them coming!

    Joe

  19. CuriousForge
    CuriousForge Says:

    forgive me, but there aren't any temp directories in C:\Program Files\, right? Nothing that will fill up over time unless you install a program yourself, right? If so, then why do you want to move the directory? Why don't you just tell each individual install to install to D:\Program Files? What am I missing?

  20. Axachi
    Axachi Says:

    Quote: Juan..

    This is a procedure under the installation.. Not afer you have installed. If you want to do that you need to do a liveCD (BartPE,LiveXP), and from there you can do this procedure.

    Hope you get tit right.

  21. Axachi
    Axachi Says:

    Duffy.. You need to change the

    "1.After installing windows 7 you will be greeted with a user creation prompt press shift+f10 and you should get a cmd window up like in the image below"

    TO
    1. Under the Installation of windows 7.......

  22. windows 7 tweaks
    windows 7 tweaks Says:

    Many thanks for your conducive article. I have been looking for this for a long time in many websites. Windows 7 is a wonderful software ever. I know a software called Win7Zilla to tweak Windows 7 efficiently

  23. bquirky
    bquirky Says:

    I successfully transferred the Users folder to my D Drive in Vista a couple of years ago. I now want to upgrade to Win 7 professional. Will the in-place upgrade option preserve the settings I have in Vista, or over-ride to the default?

  24. Axachi
    Axachi Says:

    Hi bquirky. I would sugest not to uppgrade.. If you can afford a new disk (or make a new partition on the one you have..) To do a fresh install. and then move stuff over..

    The uppgrade is and can be messy.. (but formose it works.)

    This is only my opinion. And I think you might get into truble with XP forwarding .. But do a backup befor you try it...

    Good luck.


Leave a Reply