Skip to content

Commit

Permalink
refactor(ONED.cmd): move OneDrive actions
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Aug 4, 2023
1 parent 8304377 commit 23fffb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/playbook/Configuration/atlas/components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
Expand All @@ -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}

Expand All @@ -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'}
Expand All @@ -73,5 +57,4 @@ actions:
# before potentially making any MS Accounts inoperable in packages.yml.
- !run:
exeDir: true
exe: 'CONVERTUSERS.cmd'
weight: 30
exe: 'CONVERTUSERS.cmd'
9 changes: 9 additions & 0 deletions src/playbook/Executables/ONED.cmd
Original file line number Diff line number Diff line change
@@ -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_"
Expand All @@ -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"
Expand Down

0 comments on commit 23fffb9

Please sign in to comment.