Skip to content

Commit 9ab4766

Browse files
committed
fix: another elevated permission issue
1 parent 68c459c commit 9ab4766

10 files changed

Lines changed: 30 additions & 60 deletions

File tree

playbook/Configuration/tweaks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ actions:
1010
# engine invocation; per-tweak order and enable/disable live in
1111
# Scripts\Tweaks\tweaks.manifest.psd1 (comment a line out to disable it).
1212
#
13-
# Every tweak is now PowerShell - there are no !task includes. Tweaks needing the
14-
# interactive user (theme/lock-screen and pin-to-Home COM) run via RunAs in their
15-
# .psd1 (the engine bounces them to the user session with Invoke-AtlasAsUser).
13+
# Every tweak is now PowerShell - there are no !task includes. Per-user shell COM
14+
# (theme, lock-screen, pin-to-Home) is applied by Initialize-NewUser at first logon,
15+
# not from these SYSTEM-context phases.
1616
#
1717
# ----------------------- END NOTES ----------------------- #
1818

playbook/Executables/AtlasModules/Scripts/Initialize-NewUser.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ if ($setupMarker -lt 1) {
161161
# Set ThemeMRU (recent themes)
162162
Set-AtlasTheme -Path "$([Environment]::GetFolderPath('Windows'))\Resources\Themes\atlas-v0.5.x-dark.theme"
163163
Set-AtlasThemeMru | Out-Null
164+
165+
# Re-pin Music & Videos to File Explorer Home (they drop off once recent files
166+
# are disabled). Shell COM against the running explorer, so it runs here at
167+
# first logon rather than from the SYSTEM install phase.
168+
try {
169+
& (Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'AtlasModules\Scripts\Tasks\Add-MusicVideosToHome.ps1')
170+
}
171+
catch {
172+
Write-Warning "Failed to pin Music & Videos to Home: $($_.Exception.Message)"
173+
}
164174
}
165175

166176
# Set lockscreen wallpaper

playbook/Executables/AtlasModules/Scripts/Tweaks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ All keys are optional except `Name`. Keys are applied in the order listed below.
4646
| `MinBuild` / `MaxBuild` | integer | Only apply on this Windows build range (inclusive). Maps the old YAML `builds: ['>=22000']` (`MinBuild = 22000`) and `builds: ['<22000']` (`MaxBuild = 21999`). Not enforced when the build number can't be read. |
4747
| `OnUpgrade` | `'Both'` (default), `'Skip'` or `'Only'` | `Skip` = fresh installs only, `Only` = upgrade installs only, `Both` = always. The default matches the legacy YAML semantics (actions without an `onUpgrade` gate ran on fresh installs and upgrades). |
4848
| `Oobe` | bool | When `$false`, the tweak is skipped during OOBE installs. |
49-
| `RunAs` | `'User'` or `'UserElevated'` | Runs the companion `Script` in the interactive user's session (via `Invoke-AtlasAsUser`) instead of in the TrustedInstaller engine process. For tweaks that drive the running shell (theme apply, pin-to-Home COM) or must act as the real user. Only affects `Script`; the other keys still run in the engine context. Requires the Tweaks phase (SYSTEM); if there is no interactive session the step is skipped with a warning. |
49+
| `RunAs` | `'User'` or `'UserElevated'` | Runs the companion `Script` in the interactive user's session (via `Invoke-AtlasAsUser`) instead of in the TrustedInstaller engine process. Only affects `Script`; the other keys still run in the engine context. **Do not use this for shell COM that restarts explorer (theme apply, pin-to-Home): during the SYSTEM install phase the child is parented under the phase, so a shell restart tears the phase down. Put that work in `Initialize-NewUser.ps1`, which runs at first logon in the real user session.** No shipped tweak currently uses `RunAs`. |
5050
| `Registry` | array of hashtables | Registry operations, see below. |
5151
| `Services` | array of hashtables | `@{ Name; StartupType (int 0-4); Operation }`. `Operation` is `'Change'` (default; writes the service key's `Start` value directly so protected services work), `'Stop'` or `'Start'`. `StartupType` is required for `Change`: 0 = Boot, 1 = System, 2 = Automatic, 3 = Manual, 4 = Disabled. |
5252
| `ScheduledTasks` | array of hashtables | `@{ Path; Operation }` with `Operation` = `'Disable'` (default) or `'Enable'`, applied via `schtasks.exe /Change`. A missing task only logs a warning. |

playbook/Executables/AtlasModules/Scripts/Tweaks/misc/add-music-videos-to-home.ps1

Lines changed: 0 additions & 6 deletions
This file was deleted.

playbook/Executables/AtlasModules/Scripts/Tweaks/misc/add-music-videos-to-home.psd1

Lines changed: 0 additions & 8 deletions
This file was deleted.

playbook/Executables/AtlasModules/Scripts/Tweaks/qol/appearance/atlas-theme-upgrade.ps1

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
@{
22
Name = 'Refresh Theme On Upgrade'
3-
Description = 'On upgrades, refreshes the theme MRU and keeps the Atlas theme as the default for new users.'
3+
Description = 'On upgrades, keeps the Atlas theme as the default for new users. The
4+
ThemeFile policy enforces the theme at the next logon without any interactive shell COM.'
45
OnUpgrade = 'Only'
5-
RunAs = 'UserElevated'
66
Registry = @(
77
# Set the Atlas theme as the default for new accounts (default-user hive, loaded
88
# during install).
99
@{ Path = 'HKU\AME_UserHive_Default\Software\Policies\Microsoft\Windows\Personalization'; Name = 'ThemeFile'; Type = 'ExpandString'; Data = '%windir%\Resources\Themes\atlas-v0.5.x-dark.theme' }
1010
)
11-
Script = 'atlas-theme-upgrade.ps1'
1211
}

playbook/Executables/AtlasModules/Scripts/Tweaks/qol/appearance/atlas-theme.ps1

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
# Companion of atlas-theme.psd1 (RunAs = UserElevated, fresh installs).
2-
# Applies the Atlas theme + lock-screen in the interactive user's session (COM
3-
# IThemeManager / WinRT lock-screen need the running shell). Best-effort: theming is
4-
# cosmetic, so a failure here must not abort the install.
1+
# Companion of atlas-theme.psd1. Runs in the install engine (TrustedInstaller); the
2+
# interactive theme/lock-screen apply lives in Initialize-NewUser (first logon).
3+
# Disables the rotating lock-screen "fun facts" for every provisioned account
4+
# (Enterprise/Education only). Dynamic subkeys under HKLM, so it can't be a static
5+
# Registry entry.
56
$ErrorActionPreference = 'Continue'
67

7-
& (Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'AtlasModules\initPowerShell.ps1')
8-
Import-Module Atlas.Themes -ErrorAction SilentlyContinue
9-
10-
$themePath = Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'Resources\Themes\atlas-v0.5.x-dark.theme'
11-
Set-AtlasTheme -Path $themePath
12-
Set-AtlasThemeMru
13-
Set-AtlasLockscreenImage
14-
15-
# Disable the rotating lock-screen "fun facts" for every provisioned account
16-
# (Enterprise/Education only). Dynamic subkeys, so it can't be a static Registry entry.
178
$creativeKey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Creative'
189
if (Test-Path -LiteralPath $creativeKey) {
1910
foreach ($userKey in (Get-ChildItem -LiteralPath $creativeKey).PSPath) {

playbook/Executables/AtlasModules/Scripts/Tweaks/qol/appearance/atlas-theme.psd1

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
@{
22
Name = 'Add Theme'
3-
Description = 'Applies the Atlas dark theme and lock-screen on fresh installs.'
4-
# Fresh installs only; the upgrade path (re-apply theme MRU + default-user theme file)
5-
# is atlas-theme-upgrade.psd1.
3+
Description = 'Lock-screen policy for fresh installs. The dark theme and lock-screen
4+
image are applied by Initialize-NewUser at first logon, where the shell COM runs in the
5+
real user session; applying them here (from the SYSTEM install phase) restarts the shell
6+
and tears down the phase.'
67
OnUpgrade = 'Skip'
7-
# Applying a theme (IThemeManager) and the lock-screen image are COM calls against the
8-
# running shell, so the companion runs in the interactive user's elevated session.
9-
RunAs = 'UserElevated'
108
Registry = @(
11-
# Reliable policy writes stay in the engine (run as TrustedInstaller) so they apply
12-
# even if the user-session theme apply below cannot run.
139
@{ Path = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization'; Name = 'LockScreenOverlaysDisabled'; Type = 'DWord'; Data = 1 }
1410
@{ Path = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'; Name = 'RotatingLockScreenEnabled'; Type = 'DWord'; Data = 0 }
1511
)

playbook/Executables/AtlasModules/Scripts/Tweaks/tweaks.manifest.psd1

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
'disable-auto-app-archival'
100100
'add-sharing-settings-shortcut'
101101
'appearance/blue-tooltips'
102-
# Theme/lock-screen COM runs in the user session via RunAs (Invoke-AtlasAsUser).
102+
# atlas-theme sets lock-screen policy; the theme itself is applied by
103+
# Initialize-NewUser at first logon (interactive shell COM).
103104
'appearance/atlas-theme'
104105
'appearance/atlas-theme-upgrade'
105106
'appearance/disallow-theme-changes'
@@ -213,8 +214,7 @@
213214
'set-profile-pictures'
214215
'backup-services'
215216
'update-client-cbs'
216-
# set-power-settings runs LAST, invoked directly from tweaks.yml after the
217-
# add-music-videos COM task (kept out of the phase run so it stays "done last").
217+
# set-power-settings runs LAST, invoked directly from tweaks.yml.
218218
)
219219
}
220220
@{
@@ -227,11 +227,8 @@
227227
'add-newUser-script'
228228
'config-oem-information'
229229
'create-shortcuts'
230-
# Shell "pin to Home" COM runs in the user session via RunAs (Invoke-AtlasAsUser).
231-
'add-music-videos-to-home'
232-
# enable-notifications runs LAST of all tweaks, invoked directly from tweaks.yml
233-
# after the add-music-videos COM task, so notifications re-enable only after
234-
# everything else.
230+
# enable-notifications runs LAST of all tweaks, invoked directly from tweaks.yml,
231+
# so notifications re-enable only after everything else.
235232
)
236233
}
237234
)

0 commit comments

Comments
 (0)