Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Windows App Store (fix #622) (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-darwish authored Feb 11, 2021
1 parent 8b7ff6a commit 746ffda
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub enum Step {
Vagrant,
Vcpkg,
Vim,
WindowsAppStore,
Wsl,
Yadm,
}
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
}
Expand Down
13 changes: 12 additions & 1 deletion src/steps/os/windows.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
5 changes: 5 additions & 0 deletions src/steps/powershell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ impl Powershell {
Powershell { path, profile }
}

#[cfg(windows)]
pub fn path(&self) -> &Option<PathBuf> {
&self.path
}

#[cfg(windows)]
pub fn windows_powershell() -> Self {
Powershell {
Expand Down

0 comments on commit 746ffda

Please sign in to comment.