From 23fffb9b8e78247a5888419e1b2a2bd4570c79b4 Mon Sep 17 00:00:00 2001 From: he3als <65787561+he3als@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:47:26 +0100 Subject: [PATCH] refactor(ONED.cmd): move OneDrive actions --- .../Configuration/atlas/components.yml | 21 ++----------------- src/playbook/Executables/ONED.cmd | 9 ++++++++ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/playbook/Configuration/atlas/components.yml b/src/playbook/Configuration/atlas/components.yml index bdd0418261..456ef1f833 100644 --- a/src/playbook/Configuration/atlas/components.yml +++ b/src/playbook/Configuration/atlas/components.yml @@ -3,13 +3,6 @@ title: Components description: Removes certain Windows components privilege: TrustedInstaller actions: - - # ------------------------- NOTES ------------------------- # - - # - Some of this is redundant with packages.yml - - # ----------------------- END NOTES ----------------------- # - # Windows Defender - !writeStatus: {status: 'Removing Windows Defender'} - !taskKill: {name: 'NisSrv'} @@ -34,7 +27,6 @@ actions: - !file: {path: 'C:\Windows\System32\drivers\WdNisDrv.sys'} - !file: {path: 'C:\Program Files\Windows Defender Advanced Threat Protection'} - !file: {path: 'C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection'} - # Remove Security Center startup item - !registryValue: {path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', value: 'SecurityHealth', operation: delete} @@ -50,15 +42,7 @@ actions: # OneDrive - !writeStatus: {status: 'Removing OneDrive'} - - !taskKill: {name: 'OneDriveStandaloneUpdater'} - - !taskKill: {name: 'OneDriveSetup'} - - !taskKill: {name: 'OneDrive*'} - - - !cmd: {command: 'C:\Windows\SysWOW64\OneDriveSetup.exe /uninstall'} - - !file: {path: 'C:\Windows\SysWOW64\OneDriveSetup.exe'} - - !file: {path: 'C:\ProgramData\Microsoft OneDrive'} - - - !run: {exeDir: true, exe: "ONED.cmd", weight: 20} + - !run: {exeDir: true, exe: "ONED.cmd"} # Update Health Tools - !writeStatus: {status: 'Removing Update Health Tools'} @@ -73,5 +57,4 @@ actions: # before potentially making any MS Accounts inoperable in packages.yml. - !run: exeDir: true - exe: 'CONVERTUSERS.cmd' - weight: 30 \ No newline at end of file + exe: 'CONVERTUSERS.cmd' \ No newline at end of file diff --git a/src/playbook/Executables/ONED.cmd b/src/playbook/Executables/ONED.cmd index 25f3ee29a9..313e01b177 100644 --- a/src/playbook/Executables/ONED.cmd +++ b/src/playbook/Executables/ONED.cmd @@ -1,6 +1,12 @@ @echo off setlocal EnableDelayedExpansion +taskkill /f /im OneDriveSetup.exe > nul 2>&1 +taskkill /f /im OneDrive.exe > nul 2>&1 +taskkill /f /im OneDriveStandaloneUpdater.exe > nul 2>&1 + +"%windir%\SysWOW64\OneDriveSetup.exe" /uninstall + for /f "usebackq tokens=2 delims=\" %%a in (`reg query "HKEY_USERS" ^| findstr /r /x /c:"HKEY_USERS\\S-.*" /c:"HKEY_USERS\\AME_UserHive_[^_]*"`) do ( REM If the "Volatile Environment" key exists, that means it is a proper user. Built in accounts/SIDs do not have this key. reg query "HKU\%%a" | findstr /c:"Volatile Environment" /c:"AME_UserHive_" @@ -9,6 +15,9 @@ for /f "usebackq tokens=2 delims=\" %%a in (`reg query "HKEY_USERS" ^| findstr / ) ) +rmdir /q /s "C:\ProgramData\Microsoft OneDrive" + + for /f "usebackq delims=" %%a in (`dir /b /a:d "C:\Users"`) do ( rmdir /q /s "C:\Users\%%a\AppData\Local\Microsoft\OneDrive" rmdir /q /s "C:\Users\%%a\OneDrive"