Skip to content

Commit

Permalink
Refactor UpdateInstall.ps1 script to download and install individually
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Herranz Ramírez committed Jan 29, 2025
1 parent c3915f2 commit 881b023
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions data/wsl/UpdateInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $SearchResult = $Searcher.Search("IsInstalled=0")
# Check if updates are available
if ($SearchResult.Updates.Count -eq 0) {
LogMessage "No updates found." -Color "Yellow"
return
return 0
}

# Display updates found
Expand All @@ -48,9 +48,11 @@ foreach ($Update in $UpdatesToInstall) {
LogMessage "Downloaded: $($Update.Title) successfully." -Color "Green"
} else {
LogMessage "Download failed for: $($Update.Title)" -Color "Yellow"
return 1
}
} catch {
LogMessage "Error downloading $($Update.Title): $_" -Color "Red"
return 1
}
}

Expand All @@ -69,11 +71,14 @@ foreach ($Update in $UpdatesToInstall) {
LogMessage "Successfully installed: $($Update.Title)" -Color "Green"
} else {
LogMessage "Installation failed for: $($Update.Title). Result code: $($InstallResult.ResultCode)" -Color "Yellow"
return 1
}
} catch {
LogMessage "Error occurred during installation of $($Update.Title): $_" -Color "Red"
return 1
}
}

# Completion message
LogMessage "Windows Update process completed."
LogMessage "Windows Update process completed."
return 0
2 changes: 1 addition & 1 deletion tests/wsl/install/update_windows.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sub run {
cmd => 'cd \\; $port.WriteLine($(.\\UpdateInstall.ps1))',
code => sub {
die("Update script finished unespectedly or timed out...")
unless wait_serial("Windows Update process completed.", timeout => 3600);
unless wait_serial('0', timeout => 3600);
}
);
save_screenshot;
Expand Down

0 comments on commit 881b023

Please sign in to comment.