Forum Discussion
namikou1610
Jan 28, 2025Tin Contributor
Unlink OneDrive folder in Windows 10
Hello I have problem with OneDrive. User is not signed in OneDrive but the folder 'C:\Users\%username%\OneDrive - My Org' exist and you can browse all file names and open files which are cached loca...
NikolinoDE
Feb 01, 2025Platinum Contributor
To unlink the OneDrive folder in Windows 10 when the user is not signed in, and avoid removing the entire user profile, you can follow these steps using PowerShell or Command Prompt (batch script). This will remove the OneDrive sync relationship and clean up the local files without needing the user to sign in.
Step 1: Stop the OneDrive Process
First, make sure OneDrive isn’t running:
Command Prompt (CMD)
taskkill /f /im OneDrive.exe
Step 2: Use Command Prompt to Unlink OneDrive Folder
Run the following commands (CMD) as an administrator:
# Stop OneDrive process
taskkill /f /im OneDrive.exe
# Uninstall OneDrive (Optional but ensures clean unlink)
%SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall
# Remove OneDrive registry keys (unlink account)
reg delete "HKEY_CURRENT_USER\Software\Microsoft\OneDrive" /f
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity\Identities" /f
reg delete "HKEY_CURRENT_USER\Software\Microsoft\IdentityCRL" /f
# Clear OneDrive cached credentials
del /q /f "%userprofile%\AppData\Local\Microsoft\OneDrive\settings\PreSignInSettingsConfig.json"
# Remove leftover OneDrive folders (adjust path as needed)
rmdir /s /q "%userprofile%\OneDrive - My Org"
rmdir /s /q "%localappdata%\Microsoft\OneDrive"Step 3: Clean Up via PowerShell (Advanced Script)
If you prefer PowerShell, use this script:
powershell
# Stop OneDrive process
Stop-Process -Name OneDrive -Force -ErrorAction SilentlyContinue
# Unlink OneDrive by removing registry keys
Remove-Item -Path "HKCU:\Software\Microsoft\OneDrive" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKCU:\Software\Microsoft\Office\16.0\Common\Identity\Identities" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "HKCU:\Software\Microsoft\IdentityCRL" -Recurse -Force -ErrorAction SilentlyContinue
# Clear cached credentials
$preSignInSettings = "$env:USERPROFILE\AppData\Local\Microsoft\OneDrive\settings\PreSignInSettingsConfig.json"
If (Test-Path $preSignInSettings) { Remove-Item $preSignInSettings -Force }
# Remove OneDrive folders
$oneDrivePath = "$env:USERPROFILE\OneDrive - My Org"
If (Test-Path $oneDrivePath) { Remove-Item -Path $oneDrivePath -Recurse -Force }
# Optional: Uninstall OneDrive if needed
Start-Process "$env:SystemRoot\SysWOW64\OneDriveSetup.exe" -ArgumentList "/uninstall" -WaitStep 4: Reboot
After running the script or commands:
- Restart the computer to finalize changes.
- The OneDrive folder should no longer appear linked to the user account.
Important Notes:
- Backup any important files before deleting folders.
- Removing registry keys affects OneDrive settings only, not other applications.
- For domain environments, consider using Group Policy to manage OneDrive settings centrally.
By following these steps, you can successfully unlink the OneDrive for Business folder in Windows 10 without removing the entire user profile. The text was created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.