Windows App Store (fix #622) (#624)

This commit is contained in:
Roey Darwish Dror
2021-02-11 06:31:59 +02:00
committed by GitHub
parent 8b7ff6a042
commit 746ffda444
4 changed files with 21 additions and 1 deletions

View File

@@ -1,9 +1,9 @@
use crate::execution_context::ExecutionContext;
use crate::executor::{CommandExt, RunType};
use crate::powershell;
use crate::terminal::print_separator;
use crate::utils::require;
use crate::{error::SkipStep, steps::git::Repositories};
use crate::{execution_context::ExecutionContext, utils::require_option};
use anyhow::Result;
use log::debug;
use std::convert::TryFrom;
@@ -85,6 +85,17 @@ pub fn windows_update(ctx: &ExecutionContext) -> Result<()> {
ctx.run_type().execute(&usoclient).arg("StartInstall").check_run()
}
pub fn upgrade_store_apps(ctx: &ExecutionContext) -> Result<()> {
let powershell = powershell::Powershell::windows_powershell();
let path = powershell.path().as_ref().unwrap();
let sudo = require_option(ctx.sudo().as_ref(), String::from("Sudo is required"))?;
print_separator("Windows Store");
println!("Updating Windows Store applications in the background");
ctx.run_type().execute(sudo).arg(path).args(&["-NoProfile", "-Command", "(Get-WmiObject -Namespace 'root\\cimv2\\mdm\\dmmap' -Class 'MDM_EnterpriseModernAppManagement_AppManagement01').UpdateScanMethod() | Out-Null"]).check_run()
}
pub fn reboot() {
Command::new("shutdown").args(&["/R", "/T", "0"]).spawn().ok();
}