Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could be nice to recommend Install-Module -Name PSWindowsUpdate if it is not installed #525

Closed
HenkPoley opened this issue Jul 28, 2023 · 8 comments
Labels
C-feature request New feature request P-Windows Windows issue

Comments

@HenkPoley
Copy link

HenkPoley commented Jul 28, 2023

Currently you see this:

── 08:49:31 - Windows Update ───────────────────────────────────────────────────
Running Windows Update. Check the control panel for progress.
Windows update failed:
   0: Command failed: `C:\Windows\system32\UsoClient.EXE ScanInstallWait`
   1: `C:\Windows\system32\UsoClient.EXE` failed: exit code: 0x80070057

Location:
   C:\Users\henk\.cargo\registry\src\index.crates.io-6f17d22bba15001f\topgrade-12.0.2\src\steps\os\windows.rs:189

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Retry? (y)es/(N)o/(s)hell/(q)uit

── 08:55:32 - Summary ──────────────────────────────────────────────────────────
..
Windows update: FAILED
..

Since UsoClient doesn't quite work on any recent version of Windows (I'm reading about failures back to 2018) it could be nice to just recommend to install the PSWindowsUpdate module, somewhere around this check:

#[cfg(windows)]
pub fn supports_windows_update(&self) -> bool {
self.path
.as_ref()
.map(|p| Self::has_module(p, "PSWindowsUpdate"))
.unwrap_or(false)
}

#[cfg(windows)]
pub fn windows_update(&self, ctx: &ExecutionContext) -> Result<()> {
let powershell = require_option(self.path.as_ref(), String::from("Powershell is not installed"))?;
debug_assert!(self.supports_windows_update());
let mut command = if let Some(sudo) = ctx.sudo() {
let mut command = ctx.run_type().execute(sudo);
command.arg(powershell);
command
} else {
ctx.run_type().execute(powershell)
};

pub fn windows_update(ctx: &ExecutionContext) -> Result<()> {
let powershell = powershell::Powershell::windows_powershell();
if powershell.supports_windows_update() {
print_separator("Windows Update");
return powershell.windows_update(ctx);
}
let usoclient = require("UsoClient")?;
print_separator("Windows Update");
println!("Running Windows Update. Check the control panel for progress.");
ctx.run_type()
.execute(&usoclient)
.arg("ScanInstallWait")
.status_checked()?;
ctx.run_type().execute(&usoclient).arg("StartInstall").status_checked()
}

@SteveLauC
Copy link
Member

Not a Windows user, so PR welcome, I am willing to provide help if got any questions during the implementation:)

@SteveLauC
Copy link
Member

And, related issue: #482

@SteveLauC SteveLauC added the C-feature request New feature request label Jul 28, 2023
@HenkPoley
Copy link
Author

HenkPoley commented Jul 28, 2023

Basically if this if fails,

if powershell.supports_windows_update() {

it should print

Since UsoClient doesn't work on most up to date Windows, install the PSWindowsUpdate with `Install-Module -Name PSWindowsUpdate`.

@HenkPoley
Copy link
Author

HenkPoley commented Jul 28, 2023

I guess you might even go ahead and run the install yourself. But it ships with a blackbox DLL: https://github.com/mgajda83/PSWindowsUpdate/tree/main/PSWindowsUpdate

But maybe that install depends on UsoClient actually working. I suppose it might work on the Enterprise targeted Windows 10 LTSC branch that is basically the 2015 version with security patches and no new features. But I think Microsoft dropped that around the release of Windows 11 (only 5 years of support).

Who would run topgrade on that though 🙈

@niStee
Copy link
Contributor

niStee commented Feb 11, 2024

Basically if this if fails,

if powershell.supports_windows_update() {

it should print

Since UsoClient doesn't work on most up to date Windows, install the PSWindowsUpdate with `Install-Module -Name PSWindowsUpdate`.

@HenkPoley implemented in #669 and can be tested.

@SteveLauC
Copy link
Member

Well, a skip reason won't be printed unless the --verbose or the --show-skipped option is passed

@niStee
Copy link
Contributor

niStee commented Oct 4, 2024

@SteveLauC This feature request can be closed as it seems to have been implemented, right? See #482 (comment).

@SteveLauC
Copy link
Member

Right, the feature requested in this issue has been implemented, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature request New feature request P-Windows Windows issue
Projects
None yet
Development

No branches or pull requests

3 participants