Files
winutil/docs/content/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveOneDrive.md
Gabi fcc57fde50 Add back Remove OneDrive (#3920)
* Update tweaks.json

* Create RemoveOneDrive.md

* Update _index.md

* Update _index.md

* Update _index.md

* Update tweaks.json

* Update tweaks.json

* Update tweaks.json

* Update RemoveOneDrive.md

* Update tweaks.json

* Update RemoveOneDrive.md

* Update tweaks.json

* Update RemoveOneDrive.md

* Update tweaks.json

* Update RemoveOneDrive.md

* Update tweaks.json

* Update RemoveOneDrive.md
2026-01-27 13:24:17 -06:00

1.2 KiB

Remove OneDrive

  "WPFTweaksRemoveOneDrive": {
    "Content": "Remove OneDrive",
    "Description": "Denys permission to remove onedrive user files than uses its own uninstaller to remove it than brings back permissions",
    "category": "z__Advanced Tweaks - CAUTION",
    "panel": "1",
    "Order": "a029_",
    "InvokeScript": [
      "
      # Deny permission to remove OneDrive folder
      icacls $Env:OneDrive /deny \"Administrators:(D,DC)\"

      Write-Host \"Uninstalling OneDrive...\"
      Start-Process 'C:\\Windows\\System32\\OneDriveSetup.exe' -ArgumentList '/uninstall' -Wait
      
      # Some of OneDrive files use explorer, and OneDrive uses FileCoAuth
      Write-Host \"Removing leftover OneDrive Files...\"
      Stop-Process -Name FileCoAuth,Explorer
      Remove-Item \"$Env:LocalAppData\\Microsoft\\OneDrive\" -Recurse -Force
      Remove-Item \"C:\\ProgramData\\Microsoft OneDrive\" -Recurse -Force

      # Grant back permission to accses OneDrive folder
      icacls $Env:OneDrive /grant \"Administrators:(D,DC)\"
      "
    ],
    "UndoScript": [
      "
      Write-Host \"Installing OneDrive\"
      winget install Microsoft.Onedrive --source winget
      "
    ],