Set the Windows 11 User Directory to a Non-System Drive

/
Simplified ChineseEnglish
Summary:
Use audit mode and an answer file on a clean Windows 11 installation to create user profiles on a non-system drive from the start.

Windows stores user profiles under C:\Users by default. Your Desktop, Documents, Downloads, and Pictures live there, along with the caches and settings that applications put in AppData. Before long, your system drive can fill up.

There are workarounds. You can change the location of folders such as Documents and Downloads through their properties, but that only moves those folders; AppData remains in place. You can modify the registry after installing the system, or use mklink /J to create a directory junction. But an existing user profile already contains old paths throughout, and permissions may not line up either, potentially causing problems when you install software or updates later.

The cleaner approach is to tell Windows where to put user profiles immediately after installation, before you create any user accounts. The first profile is then created in the right place from the start. Microsoft provides a configuration setting for this: ProfilesDirectory in an answer file. Here is how to use it on a clean Windows 11 installation.

How it works

ProfilesDirectory is a setting in the Microsoft-Windows-Shell-Setup component, under FolderLocations. It takes effect during the oobeSystem configuration pass. OOBE is the out-of-box setup flow after installation: choosing a region, connecting to a network, and creating an account. The user directory is created after this stage.

You therefore need to give Windows an answer file containing this setting before proceeding through OOBE. Audit mode provides an environment between installation and OOBE where you can sign in as the built-in administrator, run Sysprep with an answer file, and then return to OOBE.

Mermaid diagram

Steps

Enter audit mode

Install Windows normally until the region selection screen appears. Stop there and press Ctrl + Shift + F3. Windows will restart and sign you in to the desktop as the built-in administrator. A Sysprep window also opens; close it, because you will run Sysprep from the command line later.

Before entering audit mode, unplug the network cable or leave Wi-Fi disconnected. Otherwise, Windows may automatically update Store apps. These user-specific app updates often cause Sysprep to fail; staying offline avoids that problem.

Prepare the data drive

The target drive must use the NTFS file system and must not be a drive that contains another copy of Windows. If it is a new drive, first initialize it, partition it, and format it in Disk Management.

Important

Drive letters in audit mode may differ from those in the installer. Check the target drive’s current letter in File Explorer before writing the answer file.

Write the answer file

Create a file in Notepad and save it in the root of the target drive. I will call it relocate.xml. Set “Save as type” to “All files” and the encoding to UTF-8.

XML
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
  <settings pass="oobeSystem">
    <component name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <FolderLocations>
        <ProfilesDirectory>D:\Users</ProfilesDirectory>
      </FolderLocations>
    </component>
  </settings>
</unattend>

processorArchitecture must match your system: ordinary 64-bit PCs use amd64, while ARM devices use arm64. ProfilesDirectory is the location you want to use; D:\Users is only an example. The path must not be empty.

Run Sysprep

Open Command Prompt as administrator. First stop the Windows Media Player Network Sharing Service, which can also cause Sysprep to fail if left running, then launch Sysprep with the answer file.

CMD
net stop wmpnetworksvc
%windir%\system32\sysprep\sysprep.exe /oobe /reboot /unattend:d:\relocate.xml

/oobe returns the system to OOBE when finished; /reboot restarts it afterward; and /unattend points to the answer file you created. After a short wait, the computer will restart and show the region selection screen again. This time, complete setup normally and create your account.

Verify the result

After entering the system, open Command Prompt.

CMD
echo %USERPROFILE%

If the output looks like D:\Users\用户名, with your own username in place of the Chinese placeholder, it worked. You can also check the registry entry that records this location.

CMD
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v ProfilesDirectory

When Sysprep fails

The Sysprep error window usually does not explain what went wrong. Check the logs in %windir%\System32\Sysprep\Panther. setupact.log records the complete process, while setuperr.log contains only errors. Search for “error” and “fail” to find the failing step.

The two common causes are the ones mentioned above: Store apps were updated while online, or the network sharing service was not stopped. For an app-related failure, the log will say something like “a package was installed for a user but was not provisioned for all users” and identify the app. Uninstall it with PowerShell, then rerun Sysprep. In the command below, replace the Chinese app-name placeholder with the actual app name.

POWERSHELL
Get-AppxPackage *应用名* | Remove-AppxPackage

Only one Sysprep instance can run at a time. Starting it again while another instance is active, or after a previous run exited abnormally, may also cause an immediate error. Restart the computer and try again.

Limitations

This method only works before user profiles are created. For a system that has already been installed and used, you need to reinstall Windows and repeat the process. One benefit is that a later reinstall can format the system drive without removing the user files on the data drive, so you can recover the files you need.

  • Loading...
  • Loading...
  • Loading...
  • Loading...
  • Loading...