1

Just wondering if anyone can successfully uninstall OneDrive using PowerShell on Windows 10/11. The uninstall flag on the executable doesn't remove it even if processes are killed first.

OneDriveSetup.exe /uninstall

The command doesn't appear to be doing anything. Need to uninstall the OneDrive that comes with the OS to install it in a way that its compatible using the machine wide installer Azure Virtual Desktop/AllUsersInstall. Manually uninstalling from control panel works but I need an unattended uninstall for Azure Image Builder.

Appreciate the help

itocdw
  • 11
  • 1
  • 2

2 Answers2

0

I removed onedrive using powershell as follow:

# as you mentioned kill the onedrive prcess
taskkill /f /im OneDrive.exe

# uninstall the onedrive
# for x64 system (I tested it on my machine)
cmd -c "%SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall"

# for x86 machines
cmd -c "%SystemRoot%\System32\OneDriveSetup.exe /uninstall"
  • Thanks for trying it. I ran those commands you provided via powershell as Admin and it just doesn't do the uninstall. Must be missing something... – itocdw Jan 14 '22 at 00:38
0

By default, OneDrive is installed per user on all supported versions of Windows. But it can be installed per machine.

To find the uninstall command (string) for your system, you can look into the registry:

Per user installation:

  • Path : HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OneDriveSetup.exe
  • Key : UninstallString

Then you can use Powershell to uninstall it using the commands as in the previous answer:

# kill the OneDrive process
TASKKILL/F /IM OneDrive.exe

# Uninstall OneDrive using the UninstallString value found in registry, for example (may vary depending on OneDrive version):
cmd -c "C:\Users\<USERNAME>\AppData\Local\Microsoft\OneDrive\21.245.1128.0002\OneDriveSetup.exe /uninstall"

If the key is not present, most probably OneDrive is installed per computer so have a look here:

Per machine installation: (may vary depending on OneDrive version and flavor)

  • Path : HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OneDriveSetup.exe
  • Key : UninstallString

Additional information can be found here:

https://docs.microsoft.com/en-us/onedrive/per-machine-installation

ZivkoK
  • 166
  • 2
  • Thank you. It looks like that uninstall value has worked (HKLM). It also had the /allusers flag on the uninstall command so not sure if that made the difference or if it wanted that particular exe/onedrive path. – itocdw Jan 16 '22 at 22:04