Skip to content

Instantly share code, notes, and snippets.

@Anonymous-Humanoid
Created February 5, 2025 01:00
Show Gist options
  • Save Anonymous-Humanoid/21770cc838f62c9a53f9067a4f6f36b6 to your computer and use it in GitHub Desktop.
Save Anonymous-Humanoid/21770cc838f62c9a53f9067a4f6f36b6 to your computer and use it in GitHub Desktop.
Changing Your OneDrive Name and Path, The Unofficial Way

Changing Your OneDrive Name and Path, The Unofficial Way

Opening notes

If you just want to move your OneDrive folder, Microsoft has an official way to do this. Don't even think about trying this.

However, if you're interested in changing your OneDrive name from the default OneDrive - Your_Business_Name_Here or Personal - Your_Name_Here, or you want to change your OneDrive path such that it doesn't automatically add OneDrive or OneDrive - Your_Business_Name_Here to the end, (e.g, for software that breaks when there's spaces in the path) then this is the guide for you.

I created this guide myself and have included all my sources as well as some quotes from them. The first time I tried this, I wrote down these notes to keep track of every bump in the road. The second time, I followed these steps exactly and had no issues outside of the known issues listed below.

This guide addresses the following:

  • Changing your OneDrive name (e.g, from OneDrive - Business_Name_Here or Personal - Your_Name_Here)
  • Chanigng your OneDrive path (e.g, from C:\Users\Your_Username_Here\OneDrive or C:\Users\Your_Username_Here\OneDrive - Your_Business_Name_Here)

WARNINGS AND NOTICES

Sources:

https://support.microsoft.com/en-us/office/restore-deleted-files-or-folders-in-onedrive-949ada80-0026-4db3-a953-c99083e6a84f

https://support.microsoft.com/en-us/office/restore-your-onedrive-fa231298-759d-41cf-bcd0-25ac53eb8a15

This section is critical. Please read it before proceeding any further.

Do rename your existing OneDrive folder, do not create a new folder and make it your OneDrive folder. If this is done, OneDrive may sync your changes, which may result in OneDrive deleting your files once this process is complete. Therefore, do not perform these steps without first checking that you either have a restore point from at least 24 hours ago, or that you're otherwise able to restore deleted data. If OneDrive deletes what it deems to be large amounts of data, a notification may be displayed, asking you if you want to delete these items. OneDrive may also display another notification when this data is approaching its permanent deletion time, at which point, restoration will no longer be possible past that time. Please check your OneDrive and restore it accordingly if necessary. Alternatively, if you have the storage capacity, consider backing up your OneDrive somewhere else before performing this operation, such as your PC.

This process is also highly centered around modifying values in the registry. Do not modify that which is not specified in this guide. Do not proceed without understanding the risks. which could include system failure, corruption or other fatal errors.

I've made both of these mistakes on separate occasions, and as a result, I've had to factory reset my PC and restore my entire OneDrive. Needless to say, be careful.

This is not my area of expertise, this is simply a collection of research paired with trial and error.

This guide is in no way endorsed by Microsoft or its affiliates.

By following this guide, you agree that you are solely liable for any results caused by the steps detailed in this guide.

Known issues

This section assumes separate local and OneDrive folders for desktop, documents, etc. as that's what this has been tested with.

In file explorer, under Desktop, (file explorer apparently treats this differently from C:\Users\your_username\Desktop) you may see a duplicate OneDrive folder. Rest assured that they both point to the same directory, it's just a visual bug.

The registry is a scary place to mess around, so if a fix or improvement is found for any of these steps, please feel free to submit a change.

Allowing registry editor access

Sources:

https://answers.microsoft.com/en-us/windows/forum/all/unable-to-save-changes-to-permissions-on-registry/ef28f83b-4eb3-47be-938f-8ff005c037be

https://answers.microsoft.com/en-us/windows/forum/all/replacing-owner-on-sub-containers-and-objects/a870e5e4-73f8-4bf7-bd2d-d842f9a007c5

All of the following sections rely on use of the registry editor, making this section is a prerequisite. Administrator access is required.

Open task manager and search for and terminate any OneDrive processes that may still be running. This is necessary so that the processes don't prevent modification of registry keys.

Open the registry editor as an administrator and navigate to the following path:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Security Center\Provider\CBP

Right click the folder and select Permissions > Advanced. In the Owner section, click Change. In the object names textbox, enter the following:

Administrators

Click Check Names, followed by Ok.

Then, in the Permissions tab, select Administrators and check the Full Control checkbox, then click Ok.

Next, in the Auditing tab, select Add > Select a principal. In the textbox, enter Administrators, then click Check Names, followed by Ok. In the Basic permissions section, select the Full Control checkbox and click Ok.

Finally, check the Replace owner on subcontainers and objects checkbox. If you don't see it, change the owner again to the same value and it'll show up beneath. Click Apply, then click Ok on the remaining windows. You may now close the registry editor.

Changing local OneDrive path

Source: https://learn.microsoft.com/en-us/answers/questions/876464/change-default-name-for-onedrive-for-business-fold

This section deals with changing the local path to a OneDrive folder. Note that the solution is geared towards business OneDrive accounts, but the steps are the same for personal accounts.

"Quit OneDrive."

Open the control panel. Search for and click on "Edit environment variables for your account." In the user variables listbox, double click any OneDrive variables whose values point to your current OneDrive path and edit them to reflect the new path you desire.

Next, in explorer, navigate to the following path:

%LOCALAPPDATA%\microsoft\onedrive\settings

"You will see the accounts as folders. If you only have one then it is Business1

In the folder edit the GUID looking ini file and on line one find and change the "c:\users\user\OneDrive - Company" to what you want ie "c:\users\user\OneDrive - Fred"

Save the file..

Rename [your] OneDrive folder "C:\Users\user\OneDrive - Company" to the same name."

Open the registry editor as an administrator, then search the registry for all instances of the current OneDrive name, (e.g, OneDrive - Company) and replace them accordingly (e.g, "%USERPROFILE%\OneDrive - Company" becomes "%USERPROFILE%\OneDrive - Fred"). This includes folder names containing the current OneDrive name (e.g, "Computer\HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1\Tenants\OneDrive - Company").

"Start OneDrive again and you will see that in Explorer the OneDrive - Company now Shows OneDrive - Fred..."

Removing invalid file explorer pinned shortcut

Source:

https://answers.microsoft.com/en-us/windows/forum/all/remove-onedrive-folder-from-file-explorer/c5f1e474-a627-43bc-9dd3-6cd56f86d6eb

After following the above steps, it's possible for the user to still have a shortcut to the old OneDrive path in the navigation pane, (i.e, file explorer sidebar) which no longer exists. This next section provides a fix.

Open the registry editor as an administrator and search for "System.IsPinnedToNameSpaceTree" (e.g, under "Computer\HKEY_USERS\S-1-5-21-633179888-2964093226-2152798673-1006_Classes\CLSID{04271989-C4D2-C018-2513-4BB447A9FBC6}") and

"...Select the...key, and on the right side, double-click the System.IsPinnedToNameSpaceTree DWORD.

Change the DWORD value from 1 to 0.

Close the registry...

Restart your computer..."

The changes are now applied and should be visible in the file explorer.

Fixing folder shortcuts

Source:

https://answers.microsoft.com/en-us/windows/forum/all/windows-10-restoring-desktop-location/829534ae-65f1-422b-bc0e-96ad3362c885

It's possible that pinning a local folder to quick access (when allowed) will instead pin its related OneDrive folder (e.g, attempting to pin "C:\Users\admin\Documents" will instead pin "C:\Users\admin\OneDrive\Documents"). This section provides a fix.

Open the registry editor as an administrator and navigate to the following path:

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

Then, for each of the data values, if the path points to OneDrive, modify the value so that it points to the local user. For example, "C:\Users\admin\OneDrive\Desktop" should be modified to "C:\Users\admin\Desktop", or equivalently, "%USERPROFILE%\Desktop".

Restart your computer to apply the changes.

Closing notes

Congratulations, you've successfully changed your OneDrive name and/or path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment