From 978d7d08638dd161082f239ed088b12302f29458 Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Sun, 30 Aug 2020 16:05:02 +0100 Subject: [PATCH] add more OneDrive cleanup scripts and categorize them --- src/application/application.yaml | 96 +++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/src/application/application.yaml b/src/application/application.yaml index 6b40297c..6538d100 100644 --- a/src/application/application.yaml +++ b/src/application/application.yaml @@ -2165,20 +2165,88 @@ actions: name: App Connector app code: PowerShell -Command "Get-AppxPackage Microsoft.Appconnector | Remove-AppxPackage" - - name: Remove OneDrive - code: |- - taskkill /f /im OneDrive.exe - %SystemRoot%\System32\OneDriveSetup.exe /uninstall - %SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall - rd "%UserProfile%\OneDrive" /q /s - rd "%LocalAppData%\Microsoft\OneDrive" /q /s - rd "%ProgramData%\Microsoft OneDrive" /q /s - rd "C:\OneDriveTemp" /q /s - del "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" /s /f /q - reg delete "HKEY_CLASSES_ROOT\CLSID{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f - reg delete "HKEY_CLASSES_ROOT\Wow6432Node\CLSID{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f - reg add "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /v System.IsPinnedToNameSpaceTree /d "0" /t REG_DWORD /f - for /f "tokens=1 delims=," %%x in ('schtasks /query /fo csv ^| find "OneDrive"') do schtasks /Delete /TN %%x /F + category: Remove OneDrive + children: + - + name: Kill OneDrive process + code: taskkill /f /im OneDrive.exe + revertCode: '"%LOCALAPPDATA%\Microsoft\OneDrive\OneDrive.exe"' + - + name: Uninstall OneDrive + code: |- + if %PROCESSOR_ARCHITECTURE%==x86 ( + %SystemRoot%\System32\OneDriveSetup.exe /uninstall 2>null + ) else ( + %SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall 2>null + ) + revertCode: |- + if %PROCESSOR_ARCHITECTURE%==x86 ( + %SystemRoot%\System32\OneDriveSetup.exe /silent + ) else ( + %SystemRoot%\SysWOW64\OneDriveSetup.exe /silent + ) + - + name: Remove OneDrive leftovers + code: |- + rd "%UserProfile%\OneDrive" /q /s + rd "%LocalAppData%\Microsoft\OneDrive" /q /s + rd "%ProgramData%\Microsoft OneDrive" /q /s + rd "%SystemDrive%\OneDriveTemp" /q /s + - + name: Delete OneDrive shortcuts + docs: https://docs.microsoft.com/en-us/sharepoint/troubleshoot/installation-and-setup/how-to-block-onedrive.exe-from-being-advertised-after-install-office-2016 + code: |- + del "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Microsoft OneDrive.lnk" /s /f /q + del "%APPDATA%\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" /s /f /q + del "%USERPROFILE%\Links\OneDrive.lnk" /s /f /q + - + name: Disable usage of OneDrive + code: |- + reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\OneDrive" /t REG_DWORD /v "DisableFileSyncNGSC" /d 1 /f + reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\OneDrive" /t REG_DWORD /v "DisableFileSync" /d 1 /f + revertCode: |- + reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\OneDrive" /t REG_DWORD /v "DisableFileSyncNGSC" /d 0 /f + reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\OneDrive" /t REG_DWORD /v "DisableFileSync" /d 0 /f + - + name: Prevent automatical OneDrive install for current user + code: reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f + revertCode: |- + if %PROCESSOR_ARCHITECTURE%==x86 ( + reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "OneDriveSetup" /t REG_SZ /d " %SystemRoot%\System32\OneDriveSetup.exe /silent" /f + ) else ( + reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "OneDriveSetup" /t REG_SZ /d "%SystemRoot%\SysWOW64\OneDriveSetup.exe /silent" /f + ) + - + name: Prevent automatic OneDrive install for new users + code: |- + reg load "HKU\Default" "%SystemDrive%\Users\Default\NTUSER.DAT" + reg delete "HKU\Default\software\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f + reg unload "HKU\Default" + revertCode: |- + reg load "HKU\Default" "%SystemDrive%\Users\Default\NTUSER.DAT" + if %PROCESSOR_ARCHITECTURE%==x86 ( + reg add "HKU\Default\software\Microsoft\Windows\CurrentVersion\Run" /V "OneDriveSetup" /t REG_SZ /d " %SystemRoot%\System32\OneDriveSetup.exe /silent" /f + ) else ( + reg add "HKU\Default\software\Microsoft\Windows\CurrentVersion\Run" /V "OneDriveSetup" /t REG_SZ /d "%SystemRoot%\SysWOW64\OneDriveSetup.exe /silent" /f + ) + reg unload "HKU\Default" + - + name: Remove OneDrive from explorer menu + code: |- + reg delete "HKCR\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f + reg delete "HKCR\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f + reg add "HKCR\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /v System.IsPinnedToNameSpaceTree /d "0" /t REG_DWORD /f + reg add "HKCR\Wow6432Node\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /v System.IsPinnedToNameSpaceTree /d "0" /t REG_DWORD /f + revertCode: |- + reg add "HKCR\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /v System.IsPinnedToNameSpaceTree /d "1" /t REG_DWORD /f + reg add "HKCR\Wow6432Node\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /v System.IsPinnedToNameSpaceTree /d "1" /t REG_DWORD /f + - + name: Delete all OneDrive related Services + code: for /f "tokens=1 delims=," %%x in ('schtasks /query /fo csv ^| find "OneDrive"') do schtasks /Delete /TN %%x /F + - + name: Delete OneDrive path from registry + docs: https://stackoverflow.com/questions/46744840/export-registry-value-to-file-and-then-set-a-variable-in-batch + code: reg delete "HKCU\Environment" /v "OneDrive" /f - category: Disable built-in Windows features children: