Skip to content

Commit 11d4b37

Browse files
committed
fix(repair src): non-hardcoded path
1 parent 52856fb commit 11d4b37

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/playbook/Executables/AtlasModules/Scripts/packageInstall.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ function ProcessCab($cabPath) {
333333
# https://github.com/Atlas-OS/Atlas/issues/1103
334334
function MakeRepairSource {
335335
$version = '38655.38527.65535.65535'
336-
$srcPath = "$windir\AtlasModules\Packages\WinSxS"
336+
$srcPath = "%SystemRoot%\AtlasModules\Packages\WinSxS"
337+
$srcPathExpanded = [System.Environment]::ExpandEnvironmentVariables($srcPath)
337338

338339
Write-Host "`nMaking repair source..." -ForegroundColor Cyan
339340
Write-Host ("-" * 84) -ForegroundColor Magenta
@@ -347,21 +348,23 @@ function MakeRepairSource {
347348
}
348349

349350
# create new repair source folder
350-
if (Test-Path $srcPath -PathType Container) {
351+
if (Test-Path $srcPathExpanded -PathType Container) {
351352
Write-Host "[INFO] Deleting old RepairSrc..."
352-
Remove-Item $srcPath -Force -Recurse
353+
Remove-Item $srcPathExpanded -Force -Recurse
353354
}
354355
Write-Host "[INFO] Creating RepairSrc path..."
355-
New-Item "$srcPath\Manifests" -Force -ItemType Directory | Out-Null
356+
New-Item "$srcPathExpanded\Manifests" -Force -ItemType Directory | Out-Null
356357

357358
# hardlink all the manifests to the repair source
358359
Write-Host "[INFO] Hard linking manifests..."
359360
foreach ($manifest in $manifests) {
360-
New-Item -ItemType HardLink -Path "$srcPath\Manifests\$manifest" -Target $manifest.FullName | Out-Null
361+
New-Item -ItemType HardLink -Path "$srcPathExpanded\Manifests\$manifest" -Target $manifest.FullName | Out-Null
361362
}
362363

363364
# adds the repair source policy
364-
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing" -Name LocalSourcePath -Value "$srcPath" -Type ExpandString | Out-Null
365+
$servicingPolicyKey = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing"
366+
if (!(Test-Path $servicingPolicyKey)) { New-Item -Path $servicingPolicyKey -Force | Out-Null }
367+
Set-ItemProperty -Path $servicingPolicyKey -Name LocalSourcePath -Value "$srcPath" -Type ExpandString -Force
365368
}
366369

367370
if ($matchedPackages) {

0 commit comments

Comments
 (0)