Microsoft OneDrive - Remove
config/tweaks.json
607 "WPFTweaksRemoveOneDrive": {
608 "Content": "Microsoft OneDrive - Remove",
609 "Description": "Denies permission to remove OneDrive user files, then uses its own uninstaller to remove it and restores the original permission afterward.",
610 "category": "z__Advanced Tweaks - CAUTION",
611 "panel": "1",
612 "InvokeScript": [
613 "
614 # Deny permission to remove OneDrive folder
615 icacls $Env:OneDrive /deny \"Administrators:(D,DC)\"
616
617 Write-Host \"Uninstalling OneDrive...\"
618 Start-Process 'C:\\Windows\\System32\\OneDriveSetup.exe' -ArgumentList '/uninstall' -Wait
619
620 # Some of OneDrive files use explorer, and OneDrive uses FileCoAuth
621 Write-Host \"Removing leftover OneDrive Files...\"
622 Stop-Process -Name FileCoAuth,Explorer
623 Remove-Item \"$Env:LocalAppData\\Microsoft\\OneDrive\" -Recurse -Force
624 Remove-Item \"C:\\ProgramData\\Microsoft OneDrive\" -Recurse -Force
625
626 # Grant back permission to access OneDrive folder
627 icacls $Env:OneDrive /grant \"Administrators:(D,DC)\"
628
629 # Disable OneSyncSvc
630 Set-Service -Name OneSyncSvc -StartupType Disabled
631 "
632 ],
633 "UndoScript": [
634 "
635 Write-Host \"Installing OneDrive\"
636 winget install Microsoft.Onedrive --source winget
637
638 # Enabled OneSyncSvc
639 Set-Service -Name OneSyncSvc -StartupType Automatic
640 "
641 ],