Add a flag to control Windows update acceptance policy (fix #310)

This commit is contained in:
Roey Darwish Dror
2020-01-30 20:42:49 +02:00
parent b91fa4e26c
commit 8c12707693
4 changed files with 19 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ impl Powershell {
}
#[cfg(windows)]
pub fn windows_update(&self, run_type: RunType) -> Result<()> {
pub fn windows_update(&self, run_type: RunType, accept_all_updates: bool) -> Result<()> {
let powershell = require_option(self.path.as_ref())?;
if !Self::has_module(&powershell, "PSWindowsUpdate") {
@@ -77,7 +77,10 @@ impl Powershell {
.execute(&powershell)
.args(&[
"-Command",
"Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -Verbose",
&format!(
"Import-Module PSWindowsUpdate; Install-WindowsUpdate -MicrosoftUpdate {} -Verbose",
if accept_all_updates { "-AcceptAll" } else { "" }
),
])
.check_run()
}