diff --git a/src/steps/os/windows.rs b/src/steps/os/windows.rs index d904aec8..a9d17864 100644 --- a/src/steps/os/windows.rs +++ b/src/steps/os/windows.rs @@ -214,7 +214,6 @@ pub fn windows_update(ctx: &ExecutionContext) -> Result<()> { Err(SkipStep("USOClient not supported.".to_string()).into()) } - } pub fn reboot() -> Result<()> { diff --git a/src/steps/powershell.rs b/src/steps/powershell.rs index cbc14ece..d1d381f2 100644 --- a/src/steps/powershell.rs +++ b/src/steps/powershell.rs @@ -95,11 +95,12 @@ impl Powershell { #[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 accept_all = if ctx.config().accept_all_windows_updates() { "-AcceptAll" } else { "" }; - + let accept_all = if ctx.config().accept_all_windows_updates() { + "-AcceptAll" + } else { + "" + }; let mut command = if let Some(sudo) = ctx.sudo() { let mut command = ctx.run_type().execute(sudo); command.arg(powershell); @@ -107,19 +108,17 @@ impl Powershell { } else { ctx.run_type().execute(powershell) }; - // Correctly format the argument list for Start-Process let argument_list = format!( "-NoProfile -Command \"Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate {} -Verbose\"", accept_all ); - // Correctly pass the entire PowerShell command as a single string to -ArgumentList command .args([ "-NoProfile", "-Command", - &format!("Start-Process -FilePath powershell -Verb runAs -ArgumentList '{}'", argument_list), + &format!("Start-Process powershell -Verb runAs -ArgumentList '{}'", argument_list), ]) .status_checked() }