Windows users folder path

Relocation of the Users and the ProgramData directories to a drive other than the drive that has the Windows directory

This article describes the changes in policy for the relocation of the Users directory and the ProgramData directory to a drive other than the %systemdrive% drive in Windows operating systems.

Original product version: В Windows 10 — all editions, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2
Original KB number: В 949977

Using the ProgramData setting to redirect folders to a drive other than the system volume will block your ability to upgrade to future versions of Windows.

By changing the default location of the user profile directories or program data folders to a volume other than the system volume, you cannot service your Windows installation. Any updates, fixes, or service packs cannot be applied to the installation. We recommend that you do not change the location of the user profile directories or program data folders.

Beginning with Windows 10, OS upgrades are supported even if user profiles are redirected to another drive. For example, if you are using Windows 8.1 with ProfilesDirectory set to D:\, you can upgrade to Windows 10.

More information

%systemdrive% is defined as the drive that contains the Windows directory. There are various reasons why you may want to relocate the Users directory or the ProgramData directory to other drives.

For Windows, the most common reasons are as follows:

  • It is easier to back up data from a single drive and from a drive that contains only user files.
  • It is easier to rebuild the operating system drive on a user’s computer if user data is located on a separate volume. In this case, the drive that contains the Windows directory can be formatted, and Windows can be reinstalled without having to worry about how to remove user data.

For Windows Server, the most common reason is as follows:

  • There are performance improvements when you relocate the Users directory and the ProgramData directory to a drive other than the operating system drive.

For information about how to use the answer file setting, see Answer Files Overview.

If you use the FolderLocations unattend setting to move user data to a location other than the %systemdrive% drive, some servicing components may not be installed. These components may include critical updates, security updates, hotfixes, and service packs.

Information that is documented in the current release of the Windows AIK and the Windows OPK

The Windows Automated Installation Kit (AIK) and the Windows OEM Preinstallation Kit (OPK) for Windows and Windows Server contain documentation warnings that are related to the usage of the Profile Directory and ProgramData unattend settings. These are the settings that let you relocate the Users directory and the ProgramData directory to locations other than their default locations. This includes other drives.

Читайте также:  Как загрузиться с точки восстановления windows

These warnings were included before the servicing stack update (update 937287) was available. This update addresses the issue that is discussed in the warning text. Windows AIK and the Windows OPK documentation reads as follows. You cannot upgrade such installations to the next version of Windows.

Setting information from the Windows AIK and Windows OPK documentation:

The Profiles Directory setting

The Profiles Directory setting specifies the path of the user profile folder.

Use this setting to move the user profile folder (typically %SYSTEMDRIVE%\Users) to another location during Setup or Sysprep. The destination path can be on a volume other than the system drive, as long as it meets the following requirements:

  • It must be on an NTFS volume.
  • It must not be the path of another operating system user profile folder.
  • It must not contain any serviceable components.

This setting can be used to keep system data separate from user data. If Windows is reinstalled on the system volume, a user who has administrative rights can manually recover data from this location.

Using ProfilesDirectory to redirect folders to a drive other than the system volume blocks upgrades. Using ProfilesDirectory to point to a directory that is not the system volume will block SKU upgrades and upgrades to future versions of Windows. For example, if you use Windows 8 together with ProfilesDirectory set to D:\, you cannot upgrade to Windows 8 Pro or to the next version of Windows. The servicing stack does not handle cross-volume transactions, and it blocks upgrades.

The ProgramData setting

The ProgramData setting specifies the path of the program data folder.

These settings should be used only in a test environment. By changing the default location of the user profile directories or program data folders to a volume other than the System volume, you cannot service your Windows installation. Any updates, fixes, or service packs cannot be applied to the installation. Microsoft recommends that you do not change the location of the user profile directories or program data folders. This is especially true for Microsoft Store apps. Changing the location of %programdata% will cause errors when you install, uninstall, or update these apps.

If you use the unattend settings to set up the operating systems that are listed in this article, we will provide commercially reasonable efforts to support your scenario.

Windows 10 User Shell Folders Restore Default Paths

This post provides you the list of User Shell Folders in Windows 10 and their default paths. If you’ve moved a shell folder earlier, you can restore it to the default location via the folder properties Location tab in most cases.

However, there are situations where the Location tab option can’t be used — i.e. when two special folders such as Music and Videos become merged and point to the same location. In that case, clicking Restore Default in the folder properties Location tab causes an error.

In such cases, resetting the respective shell folder path(s) in the registry is the only possible solution. This article provides the .reg files needed to revert to the default shell folder paths quickly, and also includes the list of shell folders and their default path for your reference.

Читайте также:  Папка temp переполнена windows 10

Reset Shell Folder Paths to Default using Registry files

  1. w10_usf_defaults_hkcu.zip – Windows 10 Shell Folder Reset defaults for HKCU*
  2. w10_usf_defaults_hklm.zip – Windows 10 Shell Folder Reset defaults for HKLM*
  3. w10_usf_clear_override_hkcu.zip– Windows 10 Clear the Overriding registry values for HKCU (See Table 2)

* HKCU is short for HKEY_CURRENT_USER & HKLM is HKEY_LOCAL_MACHINE

List of Shell folders & their default locations in Windows 10

Per-User: For the current user account, the special folder paths are stored in the following registry key:

Shell Folder Name — Value type: REG_EXPAND_SZ Location
<374de290-123f-4565-9164-39c4925e467b> %USERPROFILE%\Downloads
AppData %USERPROFILE%\AppData\Roaming
Cache %USERPROFILE%\AppData\Local\Microsoft\Windows\INetCache
Cookies %USERPROFILE%\AppData\Local\Microsoft\Windows\INetCookies
Desktop %USERPROFILE%\Desktop
Favorites %USERPROFILE%\Favorites
History %USERPROFILE%\AppData\Local\Microsoft\Windows\History
Local AppData %USERPROFILE%\AppData\Local
My Music %USERPROFILE%\Music
My Pictures %USERPROFILE%\Pictures
My Video %USERPROFILE%\Videos
NetHood %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Network Shortcuts
Personal %USERPROFILE%\Documents
PrintHood %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
Programs %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Recent %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Recent
SendTo %USERPROFILE%\AppData\Roaming\Microsoft\Windows\SendTo
Start Menu %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu
Startup %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Templates %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Templates

Note: <374de290-123f-4565-9164-39c4925e467b>represents the Downloads folder.

Overriding registry values

The following items do not exist in a clean install of Windows 10, but they’re created only if you redirect those folders to Microsoft OneDrive. If the following values exist, the location defined in the following values takes precedence. In case of any conflict, the following values can be deleted so that the defaults (above) are used.

To clear or reset to defaults all of these values below, download w10_usf_clear_override_hkcu.zip.

Logoff and login back for the change to take effect.

Value Name (Overrides) Shell folder whose path is Overridden
<3b193882-d3ad-4eab-965a-69829d1fb59f> Saved Pictures
Camera Roll
Screenshots
Local Documents
<7d83ee9b-2244-4e70-b1f5-5393042af1e4> Local Downloads
Local Music
<0ddd015d-b06c-45d5-8c4c-f59713854639> Local Pictures
<35286a68-3c57-41a1-bbb1-0eae73d76c95> Local Videos

Per-System: The common special folder paths are stored in the following registry key:

Shell Folder Name — Value type: REG_EXPAND_SZ Location
<3d644c9b-1fb8-4f30-9b45-f670235f79c0> %PUBLIC%\Downloads
Common AppData %ProgramData%
Common Desktop %PUBLIC%\Desktop
Common Documents %PUBLIC%\Documents
Common Programs %ProgramData%\Microsoft\Windows\Start Menu\Programs
Common Start Menu %ProgramData%\Microsoft\Windows\Start Menu
Common Startup %ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup
Common Templates %ProgramData%\Microsoft\Windows\Templates
CommonMusic %PUBLIC%\Music
CommonPictures %PUBLIC%\Pictures
CommonVideo %PUBLIC%\Videos

Note:

  • <3d644c9b-1fb8-4f30-9b45-f670235f79c0>value represents the Public Downloads folder.
  • The values CommonMusic , CommonPictures , CommonVideo are single words (no space in them.)

How do I change the User Profile location in Windows 10?

The default location for User Profiles are C:\Users . I would like to move this location to another drive (i.e. D:\Users ). I’ve already been able to customize the library locations, however there are other things that I like to migrate as well. Is there a simple way to change the default location of the User Profiles?

4 Answers 4

WARNING: Create a backup and a restore point before you try this. I messed up once and had to do a restore myself!

Requires local admin.

Move files that you want to keep from your profile somewhere independent, for example directly on the C: or D: drive

Modify the registry value of ProfilesDirectory under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList to point to your new directory. This will only come into effect for new profiles

Create a temporary user with admin rights on the local computer. This is needed to remove your domain user profile so it can be recreated.

Log out of your account and log into the temporary admin user.

Find Advanced System Settings (for example through Start | Run and typing sysdm.cpl ) and select Settings from the User Profile section.

Find the username of your domain user and click the Delete button

I recommend using Switch Accounts rather than logging out of the temporary account. That way, if something went wrong, you still have one account that’s working

Switch accounts and log in with your domain user. The profile should now be recreated in the correct location.

Getting user temporary folder path in Windows

How I can get the user’s temp folder path in C++? My program has to run on Windows Vista and XP and they have different temp paths. How I can get it without losing compatibility?

9 Answers 9

Is there a reason you can’t use the Win32 GetTempPath API?

This API is available starting with W2K and hence will be available on all of your listed targets.

Since C++ 17 you can use a cross-platform function: std::filesystem::temp_directory_path()

The GetTempPath function retrieves the path of the directory designated for temporary files. This function supersedes the GetTempDrive function.

Parameters

Specifies the size, in characters, of the string buffer identified by lpBuffer.

Points to a string buffer that receives the null-terminated string specifying the temporary file path.

Return Values

If the function succeeds, the return value is the length, in characters, of the string copied to lpBuffer, not including the terminating null character. If the return value is greater than nBufferLength, the return value is the size of the buffer required to hold the path. If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The GetTempPath function gets the temporary file path as follows:

  1. The path specified by the TMP environment variable.
  2. The path specified by the TEMP environment variable, if TMP is not defined.
  3. The current directory, if both TMP and TEMP are not defined.

How can I get the path of a Windows “special folder” for a specific user?

Inside a service, what is the best way to determine a special folder path (e.g., «My Documents») for a specific user? SHGetFolderPath allows you to pass in a token, so I am assuming there is some way to impersonate the user who’s folder you are interested in.

Is there a way to do this based just on a username? If not, what is the minimum amount of information you need for the user account? I would rather not have to require the user’s password.

4 Answers 4

I would mount the user’s registry hive and look for the path value. Yes, it’s a sub-optimal solution, for all the reasons mentioned (poor forwards compatibility, etc.). However, like many other things in Windows, MS didn’t provide an API way to do what you want to do, so it’s the best option available.

You can get the SID (not GUID) of the user by using LookupAccountName. You can load the user’s registry hive using LoadUserProfile, but unfortunately this also requires a user token, which is going to require their password. Fortunately, you can manually load the hive using RegLoadKey into an arbitrary location, read the data, and unload it (I think).

Yes, it’s a pain, and yes, it’s probably going to break in future versions of Windows. Perhaps by that time MS will have provided an API to do it, back-ported it into older versions of Windows, and distributed it automatically through Windows update. but I wouldn’t hold my breath.

Читайте также:  При установке windows тормозит компьютер
Оцените статью