How to disable User Folder Backup to OneDrive

The automatic user folder backup in OneDrve is one the things many would like to disable, as it silently moves your files in desktop, documents, pictures, and other folders to the cloud. It is very annoying to find one day that your files are no longer in their place, and you need an Internet connection to access them.

User folder backup in OneDrive is a feature that allows you to automatically back up your important folders in Windows, such as Desktop, Documents, and Pictures, to OneDrive. This feature is available on Windows 10 and Windows 11 devices that have OneDrive installed and configured.

When you turn on user folder backup in OneDrive, it will automatically sync any changes made to the files in your Desktop, Documents, Videos, Musici and Pictures folders. That means you can access those files from anywhere with an Internet connection. This can help ensure that you always have access to your important files, even if your device is lost or damaged.

The user folder backup is not enabled by default, it requires you to explicitly turn on it manually. To turn on user folder backup in OneDrive, you can follow these steps.

Turn on user folder backup in OneDrive

  1. Run the OneDrive app and sign in to it with your Microsoft Account if required.
  2. Click the OneDrive icon in the notification area.
  3. Now, click on the gear icon in the flyout and select "Settings" from its menu.
  4. Switch to the "Sync and Backup" tab, and then click "Manage backup".
  5. Select the folders you want to back up, and then select "Save changes". By default, all folders will be selected.

Once you have completed these steps, your Desktop, Documents, Pictures, and other folders will be backed up to OneDrive.

It is worth noting that if your profile folders together occupy more space than what the OneDrive can host, it won't move the files, and the "Save changes" button will appear grayed out.

But you may ask, "Why do I have to disable in advance something that is not enabled by default?"

Microsoft persuades the user to enable backup for their profile folder. So Windows displays the appropriate button at the right moment. That button may appear unexpectedly among other suggestions for setting up the operating system, such as pre-login marketing screens which appear after you have installed a new build or cumulative updates.

Sadly, Microsoft may, at times,  put undue pressure on the user.

For instance, the OS may propose moving personal folders to the cloud as a backup measure against ransomware. For that, the Windows Security app shows a warning on the "App & browser control" page. The yellow icon and the button in the Windows Security app is a call to action.

Many users have never had such an intention. The move of their local is an entirely unwanted behavior.

As a preventative action, you may stop OneDrive from backing up the user folders to the cloud with these two simple methods. Going ahead, you can combine them to ensure that your files will always remain on your local drive. So you will prevent OneDrive from moving files and folders to Microsoft's servers.

Disable OneDrive User Folder Backup

  1. Open the Registry editor; for that press Win + R, type regedit, and hit Enter.
  2. In the left pane, navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft key.
  3. Right-click the Microsoft folder on the left, and select New > Key from the menu.
  4. Name the new key as OneDrive.
  5. Now, right-click the OneDrive key you created, and select New > DWORD (32-bit) Value.
  6. Name the new value KFMBlockOptIn and double-click it to edit its value data. Set it to 1.
  7. Finally, restart Windows.

You are done.

To undo the change, you need to simply delete the KFMBlockOptIn value and restart the OS.

The reviewed KFMBlockOptIn value manages a Group Policy that will disable OneDrive user folder backup and stop it from taking over your files. For that, it must be set to 1 in the Registry.

If you have never been fond of editing the Registry, you may prefer the two alternative solutions provided below. The first solution involves a one-line command that modifies the Registry correctly. The second one is two REG files.

Command Prompt method

A single command that involves the console REG.EXE utility will disable user's known folders backup by OneDrive. It will prevent the OneDrive app from moving your folders and files. But you have to run the command as Administrator.

  1. Open command prompt as Administrator by pressing Win + R, typing cmd.exe in the Run box, and then pressing Ctrl + Shift + Enter.
  2. In the elevated command prompt window, type or paste the following command: reg add HKLM\SOFTWARE\Policies\Microsoft\OneDrive /v KFMBlockOptIn /t REG_DWORD /d 1 /f.
  3. Hit Enter to disable the cloud backup offer and stop OneDrive from moving your folders.

Done. You can now close the console. For your convenience, you can undo the change from the command prompt as well with the following command.

reg delete HKLM\SOFTWARE\Policies\Microsoft\OneDrive /v KFMBlockOptIn /f

Download ready-made REG files

Alternatively, you can download the ready-to-use REG files to get the things done with a couple of clicks.

Download the ZIP archive with two files from this link. Extract the downloaded archive to any folder, e.g. you can place the REG files right on the desktop.

Now, open (double-click) the following file in File Explorer.

  1. disable onedrive user folder backup.reg - configure OneDrive to never upload your data to the cloud.
  2. restore defaults for onedrive user folder backup.reg - restores the default behavior.

As you may know, some editions of Windows don't support Group Policy. Also, some of them only support a limited set of policy options. If this is your case, you can apply a different solution.

Prevent OneDrive from moving files and  user folders

  1. Right-click the Start button in the taskbar, the one with the Windows icon.
  2. Select Terminal(Admin) from the menu.
  3. Now, switch to the Command Prompt tab in Terminal. For that, press Ctrl + Shift + 2 or use the arrow-down menu button.
  4. Type the following command, one after one. Press Enter after each command. Correct the folder paths if you customized their locations.
    1. mklink %userprofile%\Desktop\explorer.exe %windir%\explorer.exe
    2. mklink %userprofile%\Documents\explorer.exe %windir%\explorer.exe
    3. mklink %userprofile%\Pictures\explorer.exe %windir%\explorer.exe
  5. Now, execute the following three commands:
    1. attrib /L +h +s %userprofile%\Desktop\explorer.exe
    2. attrib /L +h +s %userprofile%\Documents\explorer.exe
    3. attrib /L +h +s %userprofile%\Pictures\explorer.exe

You are done! From now, OneDrive won't be able to move the folders to the online storage.

How does it work

Automatic transfer of a folder is not possible if it contains a symbolic link. This is because symbolic links are not actual files or folders, but rather a reference to another file or folder on the system. OneDrive cannot process them, so placing a symlink to any file inside the Desktop, Documents, or Pictures folder will prevent OneDrive from moving it to the online storage.

The mklink command in our guide creates a symbolic link to the Explorer.exe file. Actually, you can use any other file of your choice to create symbolic links for. But the file should be located outside of the known user folders.

Finally, the attrib command makes the symbolic link hidden and system, so it doesn't appear in File Explorer and don't annoy you with its presence. But you will see it when you enable hidden and system files.

Everything above can be automated with a PowerShell script.

PowerShell Script

Here's a simple PowerShell script that prevents OneDrive from moving the user folders. It automates the symlink creation in all the folders that OneDrive handles. The script can also properly detects the current folder location, and automatically sets the needed file attributes for symlinks.

You can download the script from here. You must run it as Administrator, otherwise it will fail to create the symbolic links.

Do the following.

  1. Open PowerShell as Administrator, e.g. by typing PowerShell in Search, right-clicking it, and selecting the eponymous entry.
  2. In PowerShell that opens, type Set-ExecutionPolicy RemoteSigned and hit Enter. This execution policy will allow you to run self-written scripts on your local device.
  3. Now, type or paste the full path to the prevent_onedrive_from_moving_user_folders.ps1 file you have downloaded, and hit Enter to run it.

Voila, the script will create the symbolic links for you. From now, OneDrive won't be able to move your files.

The source code for the script looks as follows.

# Credits for this code go to Vadim Sterkin
# His original post https://www.outsidethebox.ms/21844/
# It is slightly modified by Sergey Tkachenko
# For this tutorial: https://winaero.com/how-to-disable-user-folder-backup-to-onedrive/

if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
    Write-Host "Insufficient privileges. Run this script as administrator." -ForegroundColor 'red'
  Exit
}
$folders = @('Desktop', 'MyDocuments', 'MyPictures', 'MyMusic', 'MyVideos')
    foreach ($folder in $folders) {
        # get the current folder path
        $link = Join-Path -Path $([Environment]::GetFolderPath("$folder")) -ChildPath "\explorer.exe"
        $src = Join-Path -Path $([Environment]::GetEnvironmentVariable("windir")) -ChildPath "\system32\explorer.exe"
        # create the symlink
        if (-not (Test-Path $link)) {
            New-Item -ItemType SymbolicLink -Path $link -Target $src
            # hide the symlink
            Get-ChildItem -Path $link | ForEach-Object {$_.Attributes += 'Hidden'; $_.Attributes += 'System'}
        }
        else {
            Write-Host "The target file $link already exists."
        }
    }

As already mentioned earlier, you can combine both methods to prevent OneDrive from moving user files and disable user folder backup. If Group Policy fails on your PC, the symbolic link method will do the trick, and vice versa.

So, now you have learned what causes OneDrive to move your files to the cloud, and how to work around this issue. But you may be interested in learning what actually happens when it is set to sync your folders.

What happens when OneDrive moves your desktop, documents, pictures, etc

After you enable the user folder sync, intentionally or by accident, the app will create the Desktop, Documents & Pictures inside its root folder. File Explorer will show them localized, so you will see their names in your language.

Then, the app moves your local files to the newly created folders. They will be uploaded to the remote storage on Microsoft's servers.

Finally, OneDrive changes the folder paths under the following Registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders.

As a result, nothing visually changes, except that a little overlay icon over the folder and file icon indicating the synchronization status is displayed on the file icons.

How to undo the folder transfer

To disable the folder synchronization, it is enough to turn off the appropriate toggle options in OneDrive settings. But here's a catch!

This won't restore your files back to the local folders in your user profile.

So, to restore the folders properly, you need to perform two steps.

  • First of all, disable the folder synchronization in the OneDrive UI.
  • Secondly, move your files from OneDrive\Desktop to the Your profile\Desktop folder.
  • Repeat the step #2 for the DocumentsPictures and other folders.

The last step is mandatory, otherwise you will end up with empty folders for your Desktop and Documents. They will remain in OneDrive.

Finally, after you disable the sync options, and moved your files, I advise you to open the Registry editor (regedit.exe), and visit the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders key. Make sure that the folders now point to the local folders, and their paths are correct. The OneDrive client app must change the paths automatically, but an extra check here is not redundant, especially if you have some important data in those folders.

Many thanks to Vadim Sterkin for sharing the prevention methods and details.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

9 thoughts on “How to disable User Folder Backup to OneDrive”

  1. Accepting that these instructions are dated, have the procedures in WinAero Tweaker been modified to do whatever has to be done to disable User Folder Backup to OneDrive from hijacking my computer (as of this date)?

    1. Winaero Tweaker is using the KFMBlockOptIn tweak.
      Despite the post is being dated, do you have issues with disabling the OneDrive backup?
      AFAIK, everything exposed in the post is still actual.

      1. I was just inquiring as the first poster wrote: “As of 6/24/2023 this method no longer works”, so I was interested in the current state of WinAero (if this makes sense).

        1. I see. But they didn’t even specify which exactly doesn’t work for them, and what they really did.
          The mklink method, for instance, drives OneDrive crazy.
          How it may not work?
          I think they did something wrong.

          1. OK, I’ll give it a go and report back. A question crossed my mind re a new Win10 installation, i.e., is there any BEST order of precedence in running WinAero; before installing O365, after installing 0365, or am I just overthinking this?

  2. Sergey,

    The answer is that I was overthinking the problem. I tried disabling OneDrive hijack both ways using WinAero, results were the same.

Leave a Reply

Your email address will not be published.

Exit mobile version
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.