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 42 posts on Tuts4Tech.

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

Contact the author

42 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. homie
    homie Says:

    I was looking for something like this but sadly it won't work for me. I've got clean preinstalled 7 64-bit customized for Sony Vaio by Sony and I keep getting error that I don't have permission to manage inspections (I can't provide the exact message, because I've got polish version of the system and the message says "BLAD: nie masz prawa do zarzadzania inspekcjami") while using robocopy on an administrator account for any of the mentioned locations. And /COPY:U doesn't work as well. Please reply ASAP.

  16. homie
    homie Says:

    Ouch, my bad, I always run cmd prompt using win+r -> cmd and I didn't know that I have to select to run the cmd as an administrator. Now it works but I cannot copy some files ("Program Files\Common Files\SpeechEngines\Microsoft\TTS20\" ones). Weird. I hope I won't be needing those later.

  17. Duffy
    Duffy Says:

    homie, your going to mess up your system trying to do this while booted into windows, please either follow the instructions in the tutorial correctly or do it via the recovery console.

  18. homie
    homie Says:

    Now I noticed what I'm doing wrong and why I couldn't get the cmd prompt using shitf+f10. I wanted to move those folders after I created the right partitions (System C:\, Programs D:\, Data E:\), because recovery application allows me only to split disc into two partitions (min. 59GB for C:\ and the rest is allocated on D:\). I don't have the Windows disc. I think I'll just again reformat the disc and do it the right way. I'll shrink the second partition later, after moving the folders, using Partition Wizard. Did I get it right this time?

  19. Will
    Will Says:

    Hello,

    Thank you very much for this tip.

    I've been trying several solutions without any success before!

    Will

  20. Donat Luigi
    Donat Luigi Says:

    Hi,

    Nice tutorial, just what I was looking for last Summer for my original Vista install. I am interested in this approach here to carry out the free upgrade form Vista to Windows 7 Home Edition 64bit with a clean install. This would produce a clean slate for my initial image back-up and do some spring cleaning of the programs installed on my new system.

    I managed to move the User Profiles and Program data using an answer file for an unattended approach last summer but not the Program Files (see link).
    http://www.msfn.org/board/relocate-c-users-d-users-t102804-pid-873267.html#entry873267

    It worked fine but I noticed that some installed programs would not start for other user than the administrator. Is it an indication that the method I follow did not cleanly and properly move the User Profile and Program data an caused some confusion (in the registry) for installed programs?

    Before starting the upgrade, I am wondering if it'd better to follow a Custom install and then consolidate and simplify my partition strategy as follow:
    C: OS and Program Files, including swap file
    D: User Profiles and Program data

    More than likely programs back-up would need to be restored with OS and Program Data, isn't it. I am mostly concerned with separating the user data form the rest.

    For such upgrade I read that the original Vista install needs to be present to carry on the Win 7 install. It is confusing, but would I then be able to remove my old partition including the one hosting Vista and create new ones to re-size them accordingly as suggested in the link below?

    http://www.sevenforums.com/tutorials/52291-partition-hard-drive-windows-7-install.html

    Thank you in advance for your comments. I look forward to finishing preparing the upgrade and to using Win 7 this week-end.

    Donat

  21. Duffy
    Duffy Says:

    Hi Donat,
    Your post is very long, I'm not to sure I understand what you are asking could you possibly be more brief about your question if any?

  22. Donat Luigi
    Donat Luigi Says:

    Thank you Duffy for following up. You are right my post is confusing and lengthy. I could not edit after I posted it. Let me try to be more concise and clearer.

    Currently my multi partition scheme is:
    C: Vista (OS and Program Files and Program File (x86) (Default))
    D: Swap (pagefile.sys)
    E: Progs (ProgramFiles and ProgramFiles(x86) for custom install)
    F: Data (Users and Program Data folders)
    H: Media (recorded TV,...)

    Going from a Vista multi- partition scheme to a similar Windows-7 set-up but where I'd like to consolidate Program Files folders to one partition and deleted the dedicate pagefile partition as follow:
    C: Win7 (Windows 7 and Program Files default folders and fixed size pagefile)
    D: Data (Users and Program Data moved by following this tutorial)
    H: Media (recorded TV,...)

    I'd like to follow your tutorial, which does use an answer file as I did last summer - it will be simpler.
    http://www.msfn.org/board/relocate-c-users-d-users-t102804-pid-873267.html#entry873267

    First, I will need to delete logical drives in the extended partition and used the free space back into the primary partition - or - delete all partitions and start from scratch this scheme.
    I read that Vista needs to be present when upgrading to Windows 7 Home Premium 64-bit using a Custom Install (Adavced option).

    Does this means I can't apply the partition scheme of my NTFS drive before starting Windows-7 install?
    Will I then be able to do this during the Windows-7 install (and before following this tutorial), once I assume it detected the presence of Vista OS for validation?

    The motivation for me to move the Users and Program data folders to a different partition following your tutorial is to easily restore the operating system and program files from a clean image if the system get bugged down over time. Is this a valid line of thought or are they caveat as suggested in the link below (e.g. ntuser.dat backup/restore issue)?
    http://superuser.com/questions/23598/moving-users-folder-on-windows-vista-to-another-partition-bad-idea

    Has anyone of you tested if restoring the OS+Programs works, in particular for Windows 7 (64bit)?

    I would move the Program Files folders too but there are not easily decoupled from the operating system and I understand that for most case they need to be restored from the same back-up image together, don't they?

    Although I was/am very set in separating the Users data from the rest of my system install and programs, this link to superuser.com gave me second thoughts. Is moving Users folder ion a different partition such a good idea?

    All this reading to decide how to organize the partition scheme for my custom system is starting to be confusing.

    I am not sure if I succeeded in writing a shorter post but I hope my questions make more sense though. Thank you for reading and answering these questions. It will great help to clarify how to best proceed with the installation of Windows-7 and start on the "right foot".

    Donat

  23. Donat Luigi
    Donat Luigi Says:

    Hi, I did post a reply yesterday but it does not display now. It was still long but the questions better framed and clearer. Was it deleted?
    Donat

  24. Duffy
    Duffy Says:

    Hi Donat,
    From what you have said I think what you want to do is get rid of
    C: Vista (OS and Program Files and Program File (x86) (Default))
    D: Swap (pagefile.sys)
    E: Progs (ProgramFiles and ProgramFiles(x86) for custom install)
    Format them and make your C: Win7 (Windows 7 and Program Files default folders and fixed size pagefile)
    Then just follow this tutorial as normal for the users documents

  25. irha
    irha Says:

    This worked beautifully, thanks for putting together this guide. However, I am now in a dilemma on how to take a backup. I usually take a fresh backup immediately after the installation and periodically after that. I wanted to use the backup using the windows 7 built-in backup tool and after selecting the "Let me choose" option, I was confused on what options to choose. It appears like I should choose the "Data Files" (which probably includes all the user profiles, so essentially c:\Users) and the entire C: drive. In addition, I think I should also choose "d:\Program Files" and "d:\ProgramData" folders. However, what I am not completely sure is if this is equivalent to the "system image" of C: drive. I could of course choose the "Include a system image of drives" option as well, but I can't seem to be able to do that for individual drives, and I certainly don't want an entire image of D:.

    In other words, my questions are:
    - Is select "Local Disk (C:)" equivalent to taking a system image of drive C:?
    - Is selecting "Data Files and Libraries" equivalent to backing up d:\Users?

  26. Duffy
    Duffy Says:

    Hi irha,
    The complete honest the answer is I don't have a clue. I've never used the backup tool.
    - Is selecting "Data Files and Libraries" equivalent to backing up d:\Users? <--- Either way if that uses C:\users or D:\users it should be ok as C:\users points to D:\users

    - Is select "Local Disk (C:)" equivalent to taking a system image of drive C:? <---- No idea on this one, imaging would however mess up the links as the physical files they related to are now on D:

  27. irha
    irha Says:

    If links could mess up, that complicates things. I just did a regular backup selecting just the "image" option (that automatically includes C: and D: drives) and when I went back to browse, I didn't see anything other than my profile directory in D: drive. Since it doesn't let me browse C: and D: drive images, I can't tell if C: drive has just the links or the actual contents of the linked folders from D: drive (I would assume just the links, as it is supposed to be an image of the drive).

    May be the right way to backup is using two separate backups, one to backup image of C: drive and another to backup the "Program Files", "ProgramData" and "Users" folders on D: drive and schedule them together, however I didn't see anyway to create multiple backup jobs. It looks like the built-in backup/restore is not flexible enough, so I may have to just install ghost.

  28. irha
    irha Says:

    Gosh.. the ghost version 14 I have, is not compatible with windows 7 and they have no free upgrade to 15. Rather than buying ghost 15, I started thinking if there is a better way to do this.

    I think what I am trying to achieve is to have a slim and usable windows base install that is easy to backup/restore and doesn't grow as fast as my applications and data. What this means is that, if I can move the profiles and any new applications (along with their data, i.e., ProgramData) out of the C drive, then I would achieve this goal, while still having the core windows install in tact on a single drive that is easy to backup and restore.

    What this means is that I should only move the c:\Users to d:\Users, while leaving the c:\Program Files and c:\ProgramData in tact and choose to "consciously" change the destination directory for most installs to be the D: drive. This is what I already do with my existing windows xp install and it has been working out reasonably well, however, the biggest problem with this is that I can't always change the installation directory, and don't have control on some others (such as those that install into "c:\Program Files\Common Files" or those that invoke silent installers of other installers). To circumvent this, I am wondering if the registry values can still be changed such that any new programs installed default to the D: drive, while leaving those that came with the base install in tact.

    This is under the assumption that any programs already installed as part of the base OS have their locations baked into registry using the old paths, so they will continue to function even though the defaults have been changed in the registry. Any new programs installed after the change will automatically get installed to the D: drive, since the defaults point to paths on this drive. Since all paths always exist, updates should be happy too, except when they get uninstalled and reinsatlled to the new location as part of the update, but that should still be OK in most of the scenarios.

    Again, the goal is to have a small enough C: drive that can at least function without D: drive, such as in a disaster scenario. Of course, you would loose all the previous user accounts and installed applications, but this should get you started quicker than a full reinstall and reconfiguration. Applications like sandboxie might also help to simplify application management.

  29. Duffy
    Duffy Says:

    Why not just image the drive with something like partimage?

  30. Peter
    Peter Says:

    I see you exclude junction points when copying the files (the /XJ option). The result is that virtual user folders like Application Data, Cookies, SendTo, etc are not copied. Won't this cause problems with legacy software?

    These junction folders are normally not visible in Explorer, you have to display protected operating system files to see them.

  31. Duffy
    Duffy Says:

    Hi, /XJ was only added to stop things looping back on itself, it doesn't cause any issues and the virtual folders are still copied. dir /a output:
    http://pastebin.com/m17589a94

  32. Peter
    Peter Says:

    Ah yes of course, because you did the move BEFORE you created the user account. (I did it using the recovery console, after the account was created. -- I know that is not what you prescribed, but I'm just testing now.)

    But, do you have an All Users symlink and a Default User junction? And your Default user, does it have NetHood and Start Menu junctions?

  33. Duffy
    Duffy Says:

    Hey Peter, This should explain it for you http://pastebin.com/m795780eb

  34. Justin
    Justin Says:

    Duffy, My disk cleanup utility seems broken after moving the Program Files, User, and ProgramData folders. What is the best way to clean up Windows 7? Which folders or commands should I check out?

  35. Duffy
    Duffy Says:

    Hi Justin,
    "My disk cleanup utility" < -- The one build into windows or other?

    The one built into windows works fine for me, if that is the one your having issues with please check your links start -> run -> cmd dir C: /a.

    Recommendations for cleanup utilities would be ccleaner.

  36. Peter
    Peter Says:

    Considering skipping junction points while copying the Users folder, I can now confirm that Windows re-creates the junction points when continuing the install. After the copy command they are missing, but after finishing the install, all junctions and symlinks are where they should be.

  37. abee
    abee Says:

    in summary,

    will it work if i just follow the original post?

  38. Peter
    Peter Says:

    While this method (as it is written in the original post) seems to work very well, it will NOT work for restoring old userprofiles on a new Windows install. (At least, that is my experience.)

    I had a Windows 7 setup the way described here for a few days, and then decided to do a reinstall (for an unrelated reason).

    Firstly, the existing (old) user folders are not used when you re-create users with the same names. Instead, new user folders named . are created.

    This can be circumvented by first renaming the old userfolder to .old, then re-creating the user and logging in to it (which creates a new userfolder named ), then deleting the new userfolder and renaming the old one back again to . However, trying to log in as the user then, either refuses to log me in (automatically logging me out again), or creates a temporary user profile folder ignoring the old profile folder.

  39. Davidh
    Davidh Says:

    Move users from c: to d: but no anything else.

    No cmd now
    No pictures
    Very limited start menu (no wmplayer for example)

  40. jordan
    jordan Says:

    I have the same issue as Davidh.

    Time to reinstall without this and just move the documents folders around. It's way too difficult to make this work :/

  41. jsa
    jsa Says:

    Hello,

    1st thankyou Duffy for putting this together.

    I had to do a couple things different to succeed, I'm posting this info for others who have similar setups. I'm installing Win7 Ultimate.

    On a Gigabyte mobo with raid drives on the SATA ports 1-4 and the boot SSD on sata port 5, the drive letters are mixed up with the BIOS drive order.

    Likewise on another PC with a pci-e highpoint raid card the drive letters needed changing before step 2.

    So after your Step 1 but before your Step 2, in the cmd window I typed,

    diskmgmt.msc /a

    This brings up disk manager where it is possible to change drive letters, partitions, etc before proceeding with your Step 2. I set the blu-ray drive to B: here, without issues, as well.

    On both PC's C:\ProgramData would not delete during Step 3 and so mklink could not make a junction to the new location E:\ProgramData.

    To work around this I used,

    MOVE /Y "C:\ProgramData" "C:\oldProgramData"

    This renamed the folder and allowed mklink to set up the junction.

    Just to be doubly sure, additionally I ran

    robocopy "c:\oldprogramdata" "E:\ProgramData" /e /zb /copyall /xj /move

    which added the /zb & /move switches.

    Note that MOVE /Y "C:\ProgramData" "E:\ProgramData" did not work giveing, Access is Denied.

    I could not delete C:\oldProgramFiles now or once windows was installed, so I booted with a WinPE disk and was able to delete it from the WinPE command line.

    On one of the PC's C:\Program Files (x86) needed this process as well.

    Cheers

    John

  42. Cririubserons
    Cririubserons Says:

    generic viagra cialis; viagra generic cialis
    cyalis generic lowest price viagra; generic lunesta myonlinemedsbiz propecia viagra
    silagra penegra silagra generic viagra cumwithusco;generic online pharmacy viagra


Leave a Reply