Skip to content

Commit 33b1ec3

Browse files
committed
refactor: ♻️ Strengthen component removal actions with explicit script path validation and guarded package invocations
Apply path validation and stop-on-error handling before invoking the Edge remover, then resolve the package installer once per run, guard for its presence, and pass explicit package sets so the component toggles execute deterministically while existing behavior stays intact
1 parent dd39528 commit 33b1ec3

File tree

1 file changed

+54
-19
lines changed

1 file changed

+54
-19
lines changed

src/playbook/Configuration/atlas/components.yml

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ title: Components
33
description: Removes certain Windows components
44
onUpgrade: false
55
actions:
6-
# Remove Security Center startup item
7-
- !registryValue: {path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', value: 'SecurityHealth', operation: delete}
6+
# Remove Security Center startup item
7+
- !registryValue: {
8+
path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run',
9+
value: 'SecurityHealth',
10+
operation: delete,
11+
}
812

913
# Disable Smart App Control
1014
# Causes slow app loading issues and sends data to Microsoft
@@ -15,47 +19,78 @@ actions:
1519
type: REG_DWORD
1620

1721
# Microsoft Edge
18-
- !writeStatus: {status: 'Removing Microsoft Edge', option: 'uninstall-edge'}
22+
- !writeStatus: {
23+
status: 'Removing Microsoft Edge',
24+
option: 'uninstall-edge',
25+
}
1926
- !powerShell:
20-
command: '& """.\AtlasModules\Scripts\ScriptWrappers\RemoveEdge.ps1""" -UninstallEdge -RemoveEdgeData -KeepAppX -NonInteractive'
27+
command: |
28+
$ErrorActionPreference = 'Stop'
29+
$scriptRoot = (Get-Location).Path
30+
$removeEdgeScript = Join-Path $scriptRoot 'AtlasModules\Scripts\ScriptWrappers\RemoveEdge.ps1'
31+
if (-not (Test-Path -LiteralPath $removeEdgeScript)) {
32+
throw "RemoveEdge script missing at $removeEdgeScript"
33+
}
34+
& $removeEdgeScript -UninstallEdge -RemoveEdgeData -KeepAppX -NonInteractive
2135
runas: currentUserElevated
2236
option: 'uninstall-edge'
2337
wait: true
2438
exeDir: true
2539
# AppX uninstallation in the script seems to fail, therefore it's not used and AME Wizard is used instead
2640
# Note that AppX Edge is removed from the latest builds of Windows, but people could be running a non-updated version
27-
- !appx: {name: 'Microsoft.MicrosoftEdge_8wekyb3d8bbwe', type: family, option: 'uninstall-edge'}
28-
- !registryKey: {path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\Microsoft.MicrosoftEdge.Stable_8wekyb3d8bbwe', operation: add, option: 'uninstall-edge'}
29-
- !registryKey: {path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\Microsoft.MicrosoftEdge_8wekyb3d8bbwe', operation: add, option: 'uninstall-edge'}
41+
- !appx: {
42+
name: 'Microsoft.MicrosoftEdge_8wekyb3d8bbwe',
43+
type: family,
44+
option: 'uninstall-edge',
45+
}
46+
- !registryKey: {
47+
path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\Microsoft.MicrosoftEdge.Stable_8wekyb3d8bbwe',
48+
operation: add,
49+
option: 'uninstall-edge',
50+
}
51+
- !registryKey: {
52+
path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\Microsoft.MicrosoftEdge_8wekyb3d8bbwe',
53+
operation: add,
54+
option: 'uninstall-edge',
55+
}
3056

3157
# OneDrive
3258
# The actual OneDrive setup in Windows is stripped at a component-level in the miscellaneous package
33-
- !writeStatus: {status: 'Removing OneDrive'}
34-
- !run: {exeDir: true, exe: 'ONED.cmd'}
59+
- !writeStatus: { status: 'Removing OneDrive' }
60+
- !run: { exeDir: true, exe: 'ONED.cmd' }
3561

3662
# Windows components and Telemetry
37-
- !writeStatus: {status: 'Removing components'}
63+
- !writeStatus: { status: 'Removing components' }
3864
- !registryKey:
3965
path: 'HKLM\OfflineSys\ControlSet001\Services\WdBoot'
4066
operation: delete
4167
option: 'defender-disable'
4268
iso: only
4369
- !powerShell:
44-
command: >-
45-
& """$([Environment]::GetFolderPath('Windows'))\AtlasModules\Scripts\packageInstall.ps1"""
46-
-InstallPackages @('*Z-Atlas-NoDefender-Package*',
70+
command: |
71+
$ErrorActionPreference = 'Stop'
72+
$packageInstaller = Join-Path $env:windir 'AtlasModules\Scripts\packageInstall.ps1'
73+
if (-not (Test-Path -LiteralPath $packageInstaller)) {
74+
throw "packageInstall.ps1 missing at $packageInstaller"
75+
}
76+
$packagesToInstall = @(
77+
'*Z-Atlas-NoDefender-Package*'
4778
'*Z-Atlas-NoTelemetry-Package*'
4879
)
49-
-NoInteraction
80+
& $packageInstaller -InstallPackages $packagesToInstall -NoInteraction
5081
option: 'defender-disable'
5182
wait: true
5283
exeDir: true
5384
- !powerShell:
54-
command: >-
55-
& """$([Environment]::GetFolderPath('Windows'))\AtlasModules\Scripts\packageInstall.ps1"""
56-
-InstallPackages @('*Z-Atlas-NoTelemetry-Package*')
57-
-UninstallPackages @('*Z-Atlas-NoDefender-Package*')
58-
-NoInteraction
85+
command: |
86+
$ErrorActionPreference = 'Stop'
87+
$packageInstaller = Join-Path $env:windir 'AtlasModules\Scripts\packageInstall.ps1'
88+
if (-not (Test-Path -LiteralPath $packageInstaller)) {
89+
throw "packageInstall.ps1 missing at $packageInstaller"
90+
}
91+
$packagesToInstall = @('*Z-Atlas-NoTelemetry-Package*')
92+
$packagesToRemove = @('*Z-Atlas-NoDefender-Package*')
93+
& $packageInstaller -InstallPackages $packagesToInstall -UninstallPackages $packagesToRemove -NoInteraction
5994
option: 'defender-enable'
6095
wait: true
6196
exeDir: true

0 commit comments

Comments
 (0)