Skip to content

Commit 9b1023c

Browse files
fix home updates
1 parent a8db21b commit 9b1023c

File tree

3 files changed

+72
-8
lines changed

3 files changed

+72
-8
lines changed

functions/private/Invoke-WinUtilISO.ps1

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,15 @@ function Invoke-WinUtilISOMountAndVerify {
124124
[void]$sync["WPFWin11ISOEditionComboBox"].Items.Add("$($img.ImageIndex): $($img.ImageName)")
125125
}
126126
if ($sync["WPFWin11ISOEditionComboBox"].Items.Count -gt 0) {
127-
$sync["WPFWin11ISOEditionComboBox"].SelectedIndex = 0
127+
# Default to Windows 11 Pro; fall back to first item if not found
128+
$proIndex = -1
129+
for ($i = 0; $i -lt $sync["WPFWin11ISOEditionComboBox"].Items.Count; $i++) {
130+
if ($sync["WPFWin11ISOEditionComboBox"].Items[$i] -match "Windows 11 Pro(?![\w ])") {
131+
$proIndex = $i
132+
break
133+
}
134+
}
135+
$sync["WPFWin11ISOEditionComboBox"].SelectedIndex = if ($proIndex -ge 0) { $proIndex } else { 0 }
128136
}
129137
})
130138
$sync["WPFWin11ISOVerifyResultPanel"].Visibility = "Visible"
@@ -513,11 +521,17 @@ function Invoke-WinUtilISOExport {
513521

514522
$outputISO = $dlg.FileName
515523
Write-Win11ISOLog "Exporting to ISO: $outputISO"
524+
516525
Set-WinUtilProgressBar -Label "Building ISO..." -Percent 10
517526

518-
# Locate oscdimg.exe (Windows ADK)
527+
# Locate oscdimg.exe (Windows ADK or winget per-user install)
519528
$oscdimg = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
520529
Select-Object -First 1 -ExpandProperty FullName
530+
if (-not $oscdimg) {
531+
$oscdimg = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
532+
Where-Object { $_.FullName -match 'Microsoft\.OSCDIMG' } |
533+
Select-Object -First 1 -ExpandProperty FullName
534+
}
521535

522536
if (-not $oscdimg) {
523537
Write-Win11ISOLog "oscdimg.exe not found. Attempting to install via winget..."
@@ -526,8 +540,9 @@ function Invoke-WinUtilISOExport {
526540
$winget = Get-Command winget -ErrorAction Stop
527541
$result = & $winget install -e --id Microsoft.OSCDIMG --accept-package-agreements --accept-source-agreements 2>&1
528542
Write-Win11ISOLog "winget output: $result"
529-
# Re-scan for oscdimg after install
530-
$oscdimg = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
543+
# Re-scan after install
544+
$oscdimg = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
545+
Where-Object { $_.FullName -match 'Microsoft\.OSCDIMG' } |
531546
Select-Object -First 1 -ExpandProperty FullName
532547
} catch {
533548
Write-Win11ISOLog "winget not available or install failed: $_"
@@ -559,7 +574,31 @@ function Invoke-WinUtilISOExport {
559574

560575
try {
561576
Write-Win11ISOLog "Running oscdimg..."
562-
$proc = Start-Process -FilePath $oscdimg -ArgumentList $oscdimgArgs -Wait -PassThru -NoNewWindow
577+
$psi = [System.Diagnostics.ProcessStartInfo]::new()
578+
$psi.FileName = $oscdimg
579+
$psi.Arguments = $oscdimgArgs -join " "
580+
$psi.RedirectStandardOutput = $true
581+
$psi.RedirectStandardError = $true
582+
$psi.UseShellExecute = $false
583+
$psi.CreateNoWindow = $true
584+
585+
$proc = [System.Diagnostics.Process]::new()
586+
$proc.StartInfo = $psi
587+
$proc.Start() | Out-Null
588+
589+
# Stream stdout and stderr line-by-line to the status log
590+
$stdoutTask = $proc.StandardOutput.ReadToEndAsync()
591+
$stderrTask = $proc.StandardError.ReadToEndAsync()
592+
$proc.WaitForExit()
593+
[System.Threading.Tasks.Task]::WaitAll($stdoutTask, $stderrTask)
594+
595+
foreach ($line in ($stdoutTask.Result -split "`r?`n")) {
596+
if ($line.Trim()) { Write-Win11ISOLog $line }
597+
}
598+
foreach ($line in ($stderrTask.Result -split "`r?`n")) {
599+
if ($line.Trim()) { Write-Win11ISOLog "[stderr]$line" }
600+
}
601+
563602
if ($proc.ExitCode -eq 0) {
564603
Set-WinUtilProgressBar -Label "ISO exported ✔" -Percent 100
565604
Write-Win11ISOLog "ISO exported successfully: $outputISO"

functions/private/Invoke-WinUtilISOScript.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ function Invoke-WinUtilISOScript {
122122
'Microsoft.BingWeather',
123123
'Microsoft.Copilot',
124124
'Microsoft.Windows.CrossDevice',
125-
'Microsoft.GamingApp',
126125
'Microsoft.GetHelp',
127126
'Microsoft.Getstarted',
128127
'Microsoft.Microsoft3DViewer',
@@ -291,7 +290,18 @@ function Invoke-WinUtilISOScript {
291290

292291
& $Log "Disabling Windows Update during OOBE (re-enabled on first logon via FirstLogon.ps1)..."
293292
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'NoAutoUpdate' 'REG_DWORD' '1'
293+
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'AUOptions' 'REG_DWORD' '1'
294+
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'UseWUServer' 'REG_DWORD' '1'
294295
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'DisableWindowsUpdateAccess' 'REG_DWORD' '1'
296+
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'WUServer' 'REG_SZ' 'http://localhost:8080'
297+
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'WUStatusServer' 'REG_SZ' 'http://localhost:8080'
298+
Set-ISOScriptReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler_Oobe\WindowsUpdate' 'workCompleted' 'REG_DWORD' '1'
299+
Remove-ISOScriptReg 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\WindowsUpdate'
300+
Set-ISOScriptReg 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config' 'DODownloadMode' 'REG_DWORD' '0'
301+
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\BITS' 'Start' 'REG_DWORD' '4'
302+
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\wuauserv' 'Start' 'REG_DWORD' '4'
303+
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\UsoSvc' 'Start' 'REG_DWORD' '4'
304+
Set-ISOScriptReg 'HKLM\zSYSTEM\ControlSet001\Services\WaaSMedicSvc' 'Start' 'REG_DWORD' '4'
295305

296306
& $Log "Preventing installation of Teams..."
297307
Set-ISOScriptReg 'HKLM\zSOFTWARE\Policies\Microsoft\Teams' 'DisableInstallation' 'REG_DWORD' '1'
@@ -317,6 +327,12 @@ function Invoke-WinUtilISOScript {
317327
Remove-Item "$tasksPath\Microsoft\Windows\Application Experience\ProgramDataUpdater" -Force -ErrorAction SilentlyContinue
318328
Remove-Item "$tasksPath\Microsoft\Windows\Chkdsk\Proxy" -Force -ErrorAction SilentlyContinue
319329
Remove-Item "$tasksPath\Microsoft\Windows\Windows Error Reporting\QueueReporting" -Force -ErrorAction SilentlyContinue
330+
Remove-Item "$tasksPath\Microsoft\Windows\InstallService" -Recurse -Force -ErrorAction SilentlyContinue
331+
Remove-Item "$tasksPath\Microsoft\Windows\UpdateOrchestrator" -Recurse -Force -ErrorAction SilentlyContinue
332+
Remove-Item "$tasksPath\Microsoft\Windows\UpdateAssistant" -Recurse -Force -ErrorAction SilentlyContinue
333+
Remove-Item "$tasksPath\Microsoft\Windows\WaaSMedic" -Recurse -Force -ErrorAction SilentlyContinue
334+
Remove-Item "$tasksPath\Microsoft\Windows\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
335+
Remove-Item "$tasksPath\Microsoft\WindowsUpdate" -Recurse -Force -ErrorAction SilentlyContinue
320336

321337
& $Log "Scheduled task files deleted."
322338

tools/autounattend.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,17 @@ $scripts = @(
449449
) -Force -ErrorAction 'SilentlyContinue' -Verbose;
450450
};
451451
{
452-
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoUpdate /f;
453-
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess /f;
452+
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoUpdate /f;
453+
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v AUOptions /f;
454+
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v UseWUServer /f;
455+
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess /f;
456+
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUServer /f;
457+
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUStatusServer /f;
458+
reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" /v DODownloadMode /f;
459+
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\BITS" /v Start /t REG_DWORD /d 3 /f;
460+
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\wuauserv" /v Start /t REG_DWORD /d 3 /f;
461+
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\UsoSvc" /v Start /t REG_DWORD /d 2 /f;
462+
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc" /v Start /t REG_DWORD /d 3 /f;
454463
};
455464
{
456465
$recallFeature = Get-WindowsOptionalFeature -Online -ErrorAction SilentlyContinue | Where-Object { $_.State -eq 'Enabled' -and $_.FeatureName -like 'Recall' };

0 commit comments

Comments
 (0)