Change location of user folders through cmd or PowerShell?
13,471
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.
Related videos on Youtube
Author by
iFreilicht
Updated on September 18, 2022Comments
-
iFreilicht over 1 year
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 likeAppData\Roaming\Microsoft\Windows\Start Menu\Programs
) and change their location as shown below: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?-
LotPings almost 7 years
-
Vomit IT - Chunky Mess Style almost 7 yearsAlso see: social.technet.microsoft.com/Forums/scriptcenter/en-US/… and helgeklein.com/blog/2015/02/… for some more detail about this task.
-
iFreilicht almost 7 years@McDonald's I think that script is much less safe as it purely modifies the registry entries. The answer LotPings linked is relying on API that is supported and maintained.
-
Biswapriyo almost 7 yearsThose can be easily done with registry. I.e. reg command.
-
-
iFreilicht almost 7 yearsI 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. -
Charlie C almost 7 yearsYou 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%.
-
JW0914 over 3 yearsUser 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 theC:
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.)