I often re-install Windows on my PC, and store all my user files on a dedicated drive, say D:.

Every time I do this, I have to manually go to C:\Users\<username>\, right-click on every single folder (and some subfolders like AppData\Roaming\Microsoft\Windows\Start Menu\Programs) and change their location as shown below:

Folder Properties Dialog, Location Tab

To make this easier, I want to write a .bat or .ps1 script that does this automatically. Is there a built-in cmdlet that lets me do this?


Is this what you're looking for? https://stackoverflow.com/questions/25709398/set-location-of-special-folders-with-powershell

It shows how to set locations for special folders, like documents, downloads etc.


There is no built in cmdlet to do this, as it is absolutely unsupported, and can break your modern applications. Read: Your start menu, cortana, and more. There is a registry key to redirect profiles, but I would not advise using it.

Reference the ProfilesDirectory key on MSDN, which does this as well. You put a path here, and it moves your profile there. Definitely not recommended, though. Read "Important usage notes"


If you just want to back it up, you could use

copy-item C:\users\username\folder D:\users\username\folder\

This would copy all contents of the folder on C:\ to the folder on D:\ Do not copy appdata from your profile, you'll have a bad time when you re-import it.

  • I don't think you are correct in saying this is unsupported. As I have shown in my question, Windows has built-in UI for this for some special folders. Of course, I can not change the location of my users appdata folder that easily, but for most folders in the user directory, this works perfectly fine. This has been a feature in Windows since at least Windows 7 if not Vista or even XP.
    – iFreilicht
    Jun 19 '17 at 8:40
  • You are correct that moving %appdata% is a bad idea. Microsoft has never officially supported the redirection of profiles as a whole. Redirecting your profile can break some or all of your modern applications due to the user-state installation not being valid for a new build if the machine is ever imaged. I would recommend mirroring out to a removable or separate drive I'd recommend McDonald's answer to you, but it looks like you're set on using the SHSetKnown function. Check the script before you apply it. It contains profile redirection, which will include %appdata%.
    – Charlie C
    Jun 22 '17 at 12:45
  • User data folders are moveable and fully supported by Windows (see Properties - Location tab), making this answer factually inaccurate. The purpose of moving user data directories is not to backup their contents, but to separate them from the C: partition for a wide variety of reasons (shrinking the C: partition, as the maximum size required then becomes <300GB; ensuring data remains separate from the OS partition, allowing for more efficient backup and restore of the OS partition; etc.)
    – JW0914
    Jan 25 '21 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.