diff --git a/src/config.rs b/src/config.rs index 1e6798dc..c02fa845 100644 --- a/src/config.rs +++ b/src/config.rs @@ -112,6 +112,7 @@ pub enum Step { Vagrant, Vcpkg, Vim, + WindowsAppStore, Wsl, Yadm, } diff --git a/src/main.rs b/src/main.rs index 20ffa992..82d51cf7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -144,6 +144,9 @@ fn run() -> Result<()> { #[cfg(windows)] { + runner.execute(Step::WindowsAppStore, "Windows App Store", || { + windows::upgrade_store_apps(&ctx) + })?; runner.execute(Step::Chocolatey, "Chocolatey", || windows::run_chocolatey(&ctx))?; runner.execute(Step::Scoop, "Scoop", || windows::run_scoop(config.cleanup(), run_type))?; } diff --git a/src/steps/os/windows.rs b/src/steps/os/windows.rs index d1ac3f3f..e0e148dd 100644 --- a/src/steps/os/windows.rs +++ b/src/steps/os/windows.rs @@ -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(); } diff --git a/src/steps/powershell.rs b/src/steps/powershell.rs index d8c4e074..3831bd0c 100644 --- a/src/steps/powershell.rs +++ b/src/steps/powershell.rs @@ -31,6 +31,11 @@ impl Powershell { Powershell { path, profile } } + #[cfg(windows)] + pub fn path(&self) -> &Option { + &self.path + } + #[cfg(windows)] pub fn windows_powershell() -> Self { Powershell {