Skip to content

Commit

Permalink
Changes in the update script
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Herranz Ramírez committed Jan 30, 2025
1 parent 96c793c commit f10b98e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 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 0
return
}

# Display updates found
Expand All @@ -48,11 +48,9 @@ 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 @@ -71,14 +69,12 @@ 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."
return 0
$port.WriteLine('0')
4 changes: 2 additions & 2 deletions tests/wsl/install/update_windows.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ sub run {

my $vbs_url = data_url("wsl/UpdateInstall.ps1");
$self->open_powershell_as_admin;
$self->run_in_powershell(cmd => "Invoke-WebRequest -Uri \"$vbs_url\" -OutFile \"C:\\UpdateInstall.ps1\"");
$self->run_in_powershell(cmd => "Invoke-WebRequest -Uri \"$vbs_url\" -OutFile \"\$env:TEMP\\UpdateInstall.ps1\"");
$self->run_in_powershell(cmd => "Set-ExecutionPolicy Bypass -Scope CurrentUser -Force");
$self->run_in_powershell(
cmd => 'cd \\; $port.WriteLine($(.\\UpdateInstall.ps1))',
cmd => "cd \$env:TEMP; .\\UpdateInstall.ps1",
code => sub {
die("Update script finished unespectedly or timed out...")
unless wait_serial('0', timeout => 3600);
Expand Down

0 comments on commit f10b98e

Please sign in to comment.