Guest User

RemoveOneDrive.ps1

a guest
May 12th, 2018
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. # Remove ALL OneDrive
  2. # Uninstall
  3. CMD /C "c:\Windows\SysWOW64\OneDriveSetup.exe /uninstall"
  4. # take ownership of the re-installer
  5. CMD /C "takeown.exe /F C:\windows\SysWOW64\OneDriveSetup.exe /A"
  6. CMD /C "icacls C:\windows\syswow64\OneDriveSetup.exe /grant Administrators:F"
  7. # Remove
  8. Remove-Item C:\Windows\SysWOW64\OneDriveSetup.exe -Force
  9. # Create (a fake .exe, 0 bytes in size)
  10. New-Item C:\Windows\SysWOW64\OneDriveSetup.exe -Force
  11. # Deny system write
  12. CMD /C "icacls C:\Windows\SysWOW64\OneDriveSetup.exe /deny Everyone:W"
  13. # Clean up random onedrive stuff
  14. Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:localappdata\Microsoft\OneDrive"
  15. Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "$env:programdata\Microsoft OneDrive"
  16. Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "C:\OneDriveTemp"
  17. Remove-Item -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
  18. # Remove 'Onedrive folder' from left side of file explorer
  19. Reg Add "HKLM\Software\Classes\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /T REG_DWORD /V "System.IsPinnedToNameSpaceTree" /D 0 /F
Advertisement
Add Comment
Please, Sign In to add comment