From c643cd7a998ae1aea35b699afd89c8f2431c6e3f Mon Sep 17 00:00:00 2001 From: Jack <74987167+jacksyrm@users.noreply.github.com> Date: Wed, 13 May 2026 19:15:29 +0100 Subject: [PATCH 1/5] refactor: move playbook inline scripts into tasks --- src/playbook/Configuration/atlas/appx.yml | 16 ++------ src/playbook/Configuration/atlas/start.yml | 23 +---------- src/playbook/Configuration/custom.yml | 21 ++-------- .../tweaks/debloat/block-razer-installs.yml | 10 +---- .../tweaks/misc/add-music-videos-to-home.yml | 12 +----- .../tweaks/misc/config-oem-information.yml | 13 +------ .../misc/delete-windows-specific-files.yml | 3 +- .../tweaks/misc/remove-efi-drive-letter.yml | 25 +----------- .../system/disable-service-host-split.yml | 9 +---- .../qol/add-sharing-settings-shortcut.yml | 6 +-- .../disable-store-search-recommendations.yml | 11 +----- .../disable-feature-updates.yml | 5 +-- .../Scripts/Tasks/Add-MusicVideosToHome.ps1 | 27 +++++++++++++ .../Tasks/Add-NetworkSharingShortcut.ps1 | 11 ++++++ .../Scripts/Tasks/Block-RazerInstaller.ps1 | 21 ++++++++++ .../Scripts/Tasks/Copy-AtlasPayload.ps1 | 30 +++++++++++++++ .../Tasks/Disable-ServiceHostSplit.ps1 | 24 ++++++++++++ .../Disable-StoreSearchRecommendations.ps1 | 20 ++++++++++ .../Scripts/Tasks/Initialize-AtlasPath.ps1 | 38 +++++++++++++++++++ .../AtlasModules/Scripts/Tasks/README.md | 7 ++++ .../Scripts/Tasks/Remove-EfiDriveLetter.ps1 | 26 +++++++++++++ .../Scripts/Tasks/Remove-PhoneLinkAppx.ps1 | 6 +++ .../Tasks/Remove-PreviousAtlasInstall.ps1 | 21 ++++++++++ .../Remove-VersionSpecificAtlasFiles.ps1 | 19 ++++++++++ .../Tasks/Save-AppxPackageSnapshot.ps1 | 10 +++++ .../Tasks/Set-AppxDeprovisionedPackages.ps1 | 20 ++++++++++ .../Scripts/Tasks/Set-FeatureUpdateTarget.ps1 | 20 ++++++++++ .../Scripts/Tasks/Set-OemInformation.ps1 | 16 ++++++++ .../Tasks/Stop-ProcessExplorerUpgrade.ps1 | 15 ++++++++ 29 files changed, 347 insertions(+), 138 deletions(-) create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-MusicVideosToHome.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-NetworkSharingShortcut.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Block-RazerInstaller.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Copy-AtlasPayload.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-ServiceHostSplit.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-StoreSearchRecommendations.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Initialize-AtlasPath.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/README.md create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Remove-EfiDriveLetter.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Remove-PhoneLinkAppx.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Remove-PreviousAtlasInstall.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Remove-VersionSpecificAtlasFiles.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Save-AppxPackageSnapshot.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Set-AppxDeprovisionedPackages.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Set-FeatureUpdateTarget.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Set-OemInformation.ps1 create mode 100644 src/playbook/Executables/AtlasModules/Scripts/Tasks/Stop-ProcessExplorerUpgrade.ps1 diff --git a/src/playbook/Configuration/atlas/appx.yml b/src/playbook/Configuration/atlas/appx.yml index 348df75e1a..3b01d66a3c 100644 --- a/src/playbook/Configuration/atlas/appx.yml +++ b/src/playbook/Configuration/atlas/appx.yml @@ -16,9 +16,7 @@ actions: # Get current AppX packages to deprovision removed ones afterward - !powerShell: - command: | - (Get-AppxPackage).PackageFamilyName | - Out-File """$([Environment]::GetFolderPath('Windows'))\AtlasModules\AtlasPackagesOld.txt""" + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Save-AppxPackageSnapshot.ps1'')' runas: currentUserElevated wait: true @@ -81,22 +79,14 @@ actions: # Removing using AME Wizard causes issues with Cross Device Experience Host installing # - !appx: {name: 'Microsoft.YourPhone*', type: family} - !powerShell: - command: | - Get-AppxPackage Microsoft.YourPhone* | Remove-AppxPackage - Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq 'Microsoft.YourPhone' } | Remove-AppxProvisionedPackage -Online + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Remove-PhoneLinkAppx.ps1'')' runas: currentUserElevated wait: true # Prevent provisioned applications from being reinstalled # https://learn.microsoft.com/en-us/windows/application-management/remove-provisioned-apps-during-update - !powerShell: - command: | - $a = """$([Environment]::GetFolderPath('Windows'))\AtlasModules\AtlasPackagesOld.txt""" - Compare-Object -ReferenceObject (Get-Content $a) -DifferenceObject ((Get-AppxPackage).PackageFamilyName) | - Where-Object { $_.SideIndicator -eq '<=' } | - Select-Object -ExpandProperty InputObject | - Foreach-Object { New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned" -Name $_ -Force }; - Remove-Item $a -Force + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Set-AppxDeprovisionedPackages.ps1'')' runas: currentUserElevated wait: true diff --git a/src/playbook/Configuration/atlas/start.yml b/src/playbook/Configuration/atlas/start.yml index 5c987b5f84..9fabc9a870 100644 --- a/src/playbook/Configuration/atlas/start.yml +++ b/src/playbook/Configuration/atlas/start.yml @@ -5,28 +5,7 @@ actions: - !writeStatus: {status: 'Setting the environment'} - !powerShell: wait: true - command: | - function Add-ToPath ([array]$Paths) { - $machine = [System.EnvironmentVariableTarget]::Machine - $separator = [IO.Path]::PathSeparator - - $Paths | ForEach-Object { - if (!(Test-Path $_ -PathType Container)) { - Write-Error """Path '$_' doesn't exist as a container.""" - } - } - - $newPath = @() - $newPath += [Environment]::GetEnvironmentVariable('PATH', $machine) -split $separator - if ($newPath.Count -eq 0) { Write-Warning 'The PATH variable is currently empty.' } - $newPath += $Paths - $newPath = $newPath | Where-Object { $_ } | Select-Object -Unique - - [Environment]::SetEnvironmentVariable('PATH', """$($newPath -join $separator)""", $machine) - } - - $modulesPath = """$([Environment]::GetFolderPath('Windows'))\AtlasModules""" - Add-ToPath """$modulesPath""", """$modulesPath\Tools""", """$modulesPath\Scripts""" + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Initialize-AtlasPath.ps1'')' ################ NO LOCAL BUILD ################ diff --git a/src/playbook/Configuration/custom.yml b/src/playbook/Configuration/custom.yml index 3d63489362..aa2e7bc64c 100644 --- a/src/playbook/Configuration/custom.yml +++ b/src/playbook/Configuration/custom.yml @@ -15,18 +15,13 @@ actions: wait: true runas: currentUserElevated - !powerShell: - command: | - Start-Process -FilePath """$windir\AtlasDesktop\6. Advanced Configuration\Process Explorer\Uninstall Process Explorer.cmd""" -ArgumentList "/silent" -WindowStyle Hidden - taskkill /IM taskmgr.exe + command: '& ".\AtlasModules\Scripts\Tasks\Stop-ProcessExplorerUpgrade.ps1"' weight: 2 wait: true exeDir: true onUpgrade: true - !powerShell: - command: | - $windir = [Environment]::GetFolderPath('Windows') - Remove-Item -LiteralPath "$windir\AtlasDesktop" -Force -Recurse - Remove-Item -LiteralPath "$windir\AtlasModules" -Force -Recurse + command: '& ".\AtlasModules\Scripts\Tasks\Remove-PreviousAtlasInstall.ps1"' wait: true exeDir: true oobe: false @@ -34,17 +29,7 @@ actions: - !writeStatus: { status: "Copying files" } - !powerShell: - command: | - $windir = [Environment]::GetFolderPath('Windows') - @( - 'AtlasModules', - 'AtlasDesktop' - ) | ForEach-Object { - if (!(Test-Path $_)) { exit 1 } - Copy-Item -Path $_ -Destination $windir -Force -Recurse - if (!$?) { exit 2 } - } - Copy-Item -Path 'Themes\*' -Destination """$windir\Resources\Themes""" -Force -Recurse + command: '& ".\AtlasModules\Scripts\Tasks\Copy-AtlasPayload.ps1"' weight: 10 wait: true exeDir: true diff --git a/src/playbook/Configuration/tweaks/debloat/block-razer-installs.yml b/src/playbook/Configuration/tweaks/debloat/block-razer-installs.yml index b80db660f2..d6a2e3212e 100644 --- a/src/playbook/Configuration/tweaks/debloat/block-razer-installs.yml +++ b/src/playbook/Configuration/tweaks/debloat/block-razer-installs.yml @@ -15,14 +15,6 @@ actions: type: REG_DWORD - !powerShell: - command: | - $razerPath = Join-Path $env:windir 'Installer\Razer' - - New-Item -Path $razerPath -ItemType Directory -Force | Out-Null - Get-ChildItem -LiteralPath $razerPath -Force -ErrorAction SilentlyContinue | - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue - - $denyRule = '*S-1-1-0:(W)' - icacls $razerPath /deny $denyRule | Out-Null + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Block-RazerInstaller.ps1'')' runas: currentUserElevated wait: true diff --git a/src/playbook/Configuration/tweaks/misc/add-music-videos-to-home.yml b/src/playbook/Configuration/tweaks/misc/add-music-videos-to-home.yml index fe9165b252..c6fcd1f91b 100644 --- a/src/playbook/Configuration/tweaks/misc/add-music-videos-to-home.yml +++ b/src/playbook/Configuration/tweaks/misc/add-music-videos-to-home.yml @@ -3,16 +3,6 @@ title: Add Music & Videos To Home description: After disabling recent files in Quick Access, Music & Videos disappear. This fixes that. actions: - !powerShell: - command: | - $o = new-object -com shell.application - $currentPins = $o.Namespace('shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}').Items() | ForEach-Object { $_.Path } - foreach ($path in @( - [Environment]::GetFolderPath('MyVideos'), - [Environment]::GetFolderPath('MyMusic') - )) { - if ($currentPins -notcontains $path) { - $o.Namespace($path).Self.InvokeVerb('pintohome') - } - } + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Add-MusicVideosToHome.ps1'')' runas: currentUser wait: true diff --git a/src/playbook/Configuration/tweaks/misc/config-oem-information.yml b/src/playbook/Configuration/tweaks/misc/config-oem-information.yml index f052fc4f2e..5b417d0963 100644 --- a/src/playbook/Configuration/tweaks/misc/config-oem-information.yml +++ b/src/playbook/Configuration/tweaks/misc/config-oem-information.yml @@ -3,18 +3,7 @@ title: Configure OEM Information description: Configures OEM information to contain the Atlas version and the Atlas Discord server actions: - !powerShell: - command: | - $version = 'AtlasVersionUndefined' - - Write-Output 'Setting boot entry name...' - bcdedit /set description """AtlasOS $(('10', '11')[[int]([System.Environment]::OSVersion.Version.Build -ge 22000)]) $version""" - - Write-Output 'Setting other versioned OEM information...' - $reportedVer = """Atlas Playbook $version""" - # Shows in Settings - Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation' -Name 'Model' -Value $reportedVer -Force - # Shows in winver - Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name 'RegisteredOrganization' -Value $reportedVer -Force + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Set-OemInformation.ps1'')' wait: true - !registryValue: path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation' diff --git a/src/playbook/Configuration/tweaks/misc/delete-windows-specific-files.yml b/src/playbook/Configuration/tweaks/misc/delete-windows-specific-files.yml index fedf785d9f..1d0d92b40a 100644 --- a/src/playbook/Configuration/tweaks/misc/delete-windows-specific-files.yml +++ b/src/playbook/Configuration/tweaks/misc/delete-windows-specific-files.yml @@ -5,7 +5,6 @@ actions: # Delete ARM-specific files # FTH files (which are also non-ARM) are deleted in its own YML - !powerShell: - command: | - Remove-Item -Path """$([Environment]::GetFolderPath('Windows'))\AtlasDesktop\4. Interface Tweaks\Start Menu\*Open-Shell*""" -Force -Recurse + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Remove-VersionSpecificAtlasFiles.ps1'')' wait: true cpuArch: 'Arm64' diff --git a/src/playbook/Configuration/tweaks/misc/remove-efi-drive-letter.yml b/src/playbook/Configuration/tweaks/misc/remove-efi-drive-letter.yml index d4b28da784..703ebcf99b 100644 --- a/src/playbook/Configuration/tweaks/misc/remove-efi-drive-letter.yml +++ b/src/playbook/Configuration/tweaks/misc/remove-efi-drive-letter.yml @@ -3,29 +3,6 @@ title: Removes the drive letter from the EFI partition. description: This happens after clean install without formatting the drive actions: - !powerShell: - command: | - try { - # Find EFI System Partition on any disk - $efiPartition = Get-Partition | Where-Object { $_.GptType -eq '{C12A7328-F81F-11D2-BA4B-00A0C93EC93B}' } | Select-Object -First 1 - - if ($null -eq $efiPartition) { - Write-Output "No EFI partition found, skipping." - exit 0 - } - - if ([string]::IsNullOrEmpty($efiPartition.DriveLetter)) { - Write-Output "EFI partition has no drive letter, skipping." - exit 0 - } - - Write-Output "Removing drive letter '$($efiPartition.DriveLetter):' from EFI partition..." - Remove-PartitionAccessPath -DiskNumber $efiPartition.DiskNumber -PartitionNumber $efiPartition.PartitionNumber -AccessPath "$($efiPartition.DriveLetter):\" - Write-Output "Successfully removed EFI partition drive letter." - } - catch { - Write-Output "Failed to remove EFI partition drive letter: $_" - # Non-fatal error, continue installation - exit 0 - } + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Remove-EfiDriveLetter.ps1'')' wait: true runas: currentUserElevated diff --git a/src/playbook/Configuration/tweaks/performance/system/disable-service-host-split.yml b/src/playbook/Configuration/tweaks/performance/system/disable-service-host-split.yml index 0154109664..94b62126c8 100644 --- a/src/playbook/Configuration/tweaks/performance/system/disable-service-host-split.yml +++ b/src/playbook/Configuration/tweaks/performance/system/disable-service-host-split.yml @@ -4,12 +4,5 @@ description: Disables Service Host splitting for much lower RAM usage and proces actions: # https://learn.microsoft.com/en-us/windows/application-management/svchost-service-refactoring - !powerShell: - command: | - Get-ChildItem 'HKLM:\SYSTEM\CurrentControlSet\Services' | - Where-Object { $_.Name -notmatch 'Xbl|Xbox' } | - Foreach-Object { - if ($null -ne (Get-ItemProperty -Path """Registry::$_""" -EA 0).Start) { - Set-ItemProperty -Path """Registry::$_""" -Name 'SvcHostSplitDisable' -Type DWORD -Value 1 -Force -EA 0 - } - } + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Disable-ServiceHostSplit.ps1'')' wait: true diff --git a/src/playbook/Configuration/tweaks/qol/add-sharing-settings-shortcut.yml b/src/playbook/Configuration/tweaks/qol/add-sharing-settings-shortcut.yml index 89e145e3a9..759e1c2999 100644 --- a/src/playbook/Configuration/tweaks/qol/add-sharing-settings-shortcut.yml +++ b/src/playbook/Configuration/tweaks/qol/add-sharing-settings-shortcut.yml @@ -3,10 +3,6 @@ title: Add Network Sharing Shortcut description: Adds a network sharing settings shortcut to the Atlas 'File Sharing' folder for QoL actions: - !powerShell: - command: | - .\AtlasModules\initPowerShell.ps1 - New-Shortcut -Source 'control.exe' ` - -Destination """$([Environment]::GetFolderPath('Windows'))\AtlasDesktop\3. General Configuration\File Sharing\Sharing Settings.lnk""" ` - -Arguments '/name Microsoft.NetworkAndSharingCenter /page Advanced' + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Add-NetworkSharingShortcut.ps1'')' exeDir: true wait: true diff --git a/src/playbook/Configuration/tweaks/qol/disable-store-search-recommendations.yml b/src/playbook/Configuration/tweaks/qol/disable-store-search-recommendations.yml index 4dd4039b37..fcffe7fef7 100644 --- a/src/playbook/Configuration/tweaks/qol/disable-store-search-recommendations.yml +++ b/src/playbook/Configuration/tweaks/qol/disable-store-search-recommendations.yml @@ -3,15 +3,6 @@ title: Disable Microsoft Store Recommended Search Results description: Disables recommended Microsoft Store apps in Start Menu actions: - !powerShell: - command: | - $storeDb = Join-Path $env:LocalAppData 'Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db' - $storeDbParent = Split-Path -Path $storeDb -Parent - - New-Item -Path $storeDbParent -ItemType Directory -Force | Out-Null - if (!(Test-Path -LiteralPath $storeDb)) { - New-Item -Path $storeDb -ItemType File -Force | Out-Null - } - - icacls $storeDb /deny "*S-1-1-0:F" | Out-Null + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Disable-StoreSearchRecommendations.ps1'')' runas: currentUserElevated wait: true diff --git a/src/playbook/Configuration/tweaks/qol/windows-update/disable-feature-updates.yml b/src/playbook/Configuration/tweaks/qol/windows-update/disable-feature-updates.yml index dac336c128..8fb4eb73f2 100644 --- a/src/playbook/Configuration/tweaks/qol/windows-update/disable-feature-updates.yml +++ b/src/playbook/Configuration/tweaks/qol/windows-update/disable-feature-updates.yml @@ -7,8 +7,5 @@ actions: # https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.WindowsUpdate::TargetReleaseVersion - !registryValue: {path: 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate', value: 'TargetReleaseVersion', data: '1', type: REG_DWORD} - !powerShell: - command: 'if ((Get-CimInstance -Class Win32_OperatingSystem).Caption -match 11) {$a = ''Windows 11''} else {$a = ''Windows 10''}; New-ItemProperty -Path ''HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate'' -Name ''ProductVersion'' -Value $a -PropertyType String -Force' - wait: true - - !powerShell: - command: '$ver = (Get-ItemProperty ''HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'').DisplayVersion; New-ItemProperty -Path ''HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate'' -Name ''TargetReleaseVersion'' -Value $ver -PropertyType String -Force' + command: '& (Join-Path ([Environment]::GetFolderPath(''Windows'')) ''AtlasModules\Scripts\Tasks\Set-FeatureUpdateTarget.ps1'')' wait: true diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-MusicVideosToHome.ps1 b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-MusicVideosToHome.ps1 new file mode 100644 index 0000000000..d09519705d --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-MusicVideosToHome.ps1 @@ -0,0 +1,27 @@ +$ErrorActionPreference = 'Stop' + +$shell = New-Object -ComObject Shell.Application +$homeNamespace = $shell.Namespace('shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}') +if ($null -eq $homeNamespace) { + throw 'Could not open the File Explorer Home namespace.' +} + +$currentPins = @($homeNamespace.Items() | ForEach-Object { $_.Path }) +foreach ($path in @( + [Environment]::GetFolderPath('MyVideos'), + [Environment]::GetFolderPath('MyMusic') +)) { + if ([string]::IsNullOrWhiteSpace($path) -or -not (Test-Path -LiteralPath $path -PathType Container)) { + Write-Warning "Skipping missing shell folder '$path'." + continue + } + + if ($currentPins -notcontains $path) { + $folder = $shell.Namespace($path) + if ($null -eq $folder) { + throw "Could not open shell namespace for '$path'." + } + + $folder.Self.InvokeVerb('pintohome') + } +} diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-NetworkSharingShortcut.ps1 b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-NetworkSharingShortcut.ps1 new file mode 100644 index 0000000000..d9f29b84e7 --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Add-NetworkSharingShortcut.ps1 @@ -0,0 +1,11 @@ +$ErrorActionPreference = 'Stop' + +$initScript = Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'AtlasModules\initPowerShell.ps1' +if (-not (Test-Path -LiteralPath $initScript -PathType Leaf)) { + throw "Atlas PowerShell initialization script '$initScript' is missing." +} + +. $initScript + +$destination = Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'AtlasDesktop\3. General Configuration\File Sharing\Sharing Settings.lnk' +New-Shortcut -Source 'control.exe' -Destination $destination -Arguments '/name Microsoft.NetworkAndSharingCenter /page Advanced' diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/Block-RazerInstaller.ps1 b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Block-RazerInstaller.ps1 new file mode 100644 index 0000000000..ef9b88aa13 --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Block-RazerInstaller.ps1 @@ -0,0 +1,21 @@ +$ErrorActionPreference = 'Stop' + +$razerPath = Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'Installer\Razer' +New-Item -Path $razerPath -ItemType Directory -Force | Out-Null + +$resolvedRazerPath = (Resolve-Path -LiteralPath $razerPath).ProviderPath +$windowsInstallerRoot = Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'Installer' +$resolvedInstallerRoot = (Resolve-Path -LiteralPath $windowsInstallerRoot).ProviderPath.TrimEnd('\') + +if (-not $resolvedRazerPath.StartsWith($resolvedInstallerRoot + '\', [StringComparison]::OrdinalIgnoreCase)) { + throw "Refusing to clear unexpected Razer installer path '$resolvedRazerPath'." +} + +Get-ChildItem -LiteralPath $resolvedRazerPath -Force -ErrorAction Stop | + Remove-Item -Recurse -Force -ErrorAction Stop + +$denyRule = '*S-1-1-0:(W)' +& icacls.exe $resolvedRazerPath /deny $denyRule | Out-Null +if ($LASTEXITCODE -ne 0) { + throw "icacls.exe failed to deny write access on '$resolvedRazerPath' with exit code $LASTEXITCODE." +} diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/Copy-AtlasPayload.ps1 b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Copy-AtlasPayload.ps1 new file mode 100644 index 0000000000..1f321944dc --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Copy-AtlasPayload.ps1 @@ -0,0 +1,30 @@ +$ErrorActionPreference = 'Stop' + +$windowsPath = [Environment]::GetFolderPath('Windows') +if ([string]::IsNullOrWhiteSpace($windowsPath) -or -not (Test-Path -LiteralPath $windowsPath -PathType Container)) { + throw "Windows directory '$windowsPath' is not available." +} + +foreach ($folderName in @('AtlasModules', 'AtlasDesktop')) { + $source = Join-Path -Path (Get-Location).Path -ChildPath $folderName + if (-not (Test-Path -LiteralPath $source -PathType Container)) { + throw "Required playbook payload folder '$source' is missing." + } + + Copy-Item -LiteralPath $source -Destination $windowsPath -Force -Recurse -ErrorAction Stop +} + +$themesSourceRoot = Join-Path -Path (Get-Location).Path -ChildPath 'Themes' +if (-not (Test-Path -LiteralPath $themesSourceRoot -PathType Container)) { + throw "Required Themes payload folder '$themesSourceRoot' is missing." +} + +$themesDestination = Join-Path -Path $windowsPath -ChildPath 'Resources\Themes' +if (-not (Test-Path -LiteralPath $themesDestination -PathType Container)) { + New-Item -Path $themesDestination -ItemType Directory -Force | Out-Null +} + +Get-ChildItem -LiteralPath $themesSourceRoot -Force -ErrorAction Stop | + ForEach-Object { + Copy-Item -LiteralPath $_.FullName -Destination $themesDestination -Force -Recurse -ErrorAction Stop + } diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-ServiceHostSplit.ps1 b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-ServiceHostSplit.ps1 new file mode 100644 index 0000000000..52a8c72e7b --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-ServiceHostSplit.ps1 @@ -0,0 +1,24 @@ +$ErrorActionPreference = 'Stop' + +# SvcHostSplitDisable reduces the process count on memory-rich systems. Xbox services are +# excluded because Game Bar and related services can fail when forced back into shared hosts. +Get-ChildItem -Path 'HKLM:\SYSTEM\CurrentControlSet\Services' -ErrorAction Stop | + Where-Object { $_.PSChildName -notmatch 'Xbl|Xbox' } | + ForEach-Object { + $servicePath = $_.PSPath + $serviceName = $_.PSChildName + $service = Get-ItemProperty -Path $servicePath -ErrorAction SilentlyContinue + if ($null -ne $service -and $null -ne $service.PSObject.Properties['Start']) { + try { + Set-ItemProperty -Path $servicePath -Name 'SvcHostSplitDisable' -Type DWord -Value 1 -Force -ErrorAction Stop + } + catch { + if ($_.FullyQualifiedErrorId -like '*UnauthorizedAccessException*' -or $_.Exception -is [System.UnauthorizedAccessException]) { + Write-Warning "Skipping protected service '$serviceName': $($_.Exception.Message)" + } + else { + throw + } + } + } + } diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-StoreSearchRecommendations.ps1 b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-StoreSearchRecommendations.ps1 new file mode 100644 index 0000000000..ab26b02db1 --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Disable-StoreSearchRecommendations.ps1 @@ -0,0 +1,20 @@ +$ErrorActionPreference = 'Stop' + +$localAppData = [Environment]::GetFolderPath('LocalApplicationData') +if ([string]::IsNullOrWhiteSpace($localAppData)) { + throw 'LocalApplicationData is not available for the current user.' +} + +$storeDb = Join-Path -Path $localAppData -ChildPath 'Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db' +$storeDbParent = Split-Path -Path $storeDb -Parent + +New-Item -Path $storeDbParent -ItemType Directory -Force | Out-Null +if (-not (Test-Path -LiteralPath $storeDb -PathType Leaf)) { + New-Item -Path $storeDb -ItemType File -Force | Out-Null +} + +$denyRule = '*S-1-1-0:F' +& icacls.exe $storeDb /deny $denyRule | Out-Null +if ($LASTEXITCODE -ne 0) { + throw "icacls.exe failed to deny Store DB access on '$storeDb' with exit code $LASTEXITCODE." +} diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/Initialize-AtlasPath.ps1 b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Initialize-AtlasPath.ps1 new file mode 100644 index 0000000000..f57e13c93a --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/Initialize-AtlasPath.ps1 @@ -0,0 +1,38 @@ +$ErrorActionPreference = 'Stop' + +function Add-AtlasPath { + param( + [Parameter(Mandatory = $true)] + [string[]]$Paths + ) + + $machine = [System.EnvironmentVariableTarget]::Machine + $separator = [IO.Path]::PathSeparator + + foreach ($path in $Paths) { + if (-not (Test-Path -LiteralPath $path -PathType Container)) { + throw "Required PATH entry '$path' does not exist as a container." + } + } + + $currentPath = [Environment]::GetEnvironmentVariable('PATH', $machine) + $newPath = @() + if (-not [string]::IsNullOrWhiteSpace($currentPath)) { + $newPath += $currentPath -split [regex]::Escape($separator) + } + else { + Write-Warning 'The machine PATH variable is currently empty.' + } + + $newPath += $Paths + $newPath = $newPath | Where-Object { $_ } | Select-Object -Unique + + [Environment]::SetEnvironmentVariable('PATH', ($newPath -join $separator), $machine) +} + +$modulesPath = Join-Path -Path ([Environment]::GetFolderPath('Windows')) -ChildPath 'AtlasModules' +Add-AtlasPath -Paths @( + $modulesPath, + (Join-Path -Path $modulesPath -ChildPath 'Tools'), + (Join-Path -Path $modulesPath -ChildPath 'Scripts') +) diff --git a/src/playbook/Executables/AtlasModules/Scripts/Tasks/README.md b/src/playbook/Executables/AtlasModules/Scripts/Tasks/README.md new file mode 100644 index 0000000000..9d70bc6c5f --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Tasks/README.md @@ -0,0 +1,7 @@ +# Atlas Task Scripts + +YAML task entries invoke these scripts with this Windows PowerShell 5.1-safe form: + + & (Join-Path ([Environment]::GetFolderPath('Windows')) 'AtlasModules\Scripts\Tasks\