Skip to content

Commit 26c9295

Browse files
feat: 自动添加 Windows Defender 白名单
close std-microblock/chromatic#389 close std-microblock/chromatic#392
1 parent e7054e1 commit 26c9295

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(fs_try_exists)]
66
#![feature(rustc_attrs)]
77
#[rustc_box]
8-
98
mod ncm_utils;
109
use std::fs;
1110
use std::path::Path;
@@ -294,6 +293,18 @@ fn ui_builder() -> impl Widget<AppData> {
294293
let event_sink = ctx.get_external_handle();
295294
let url: String = data.latest_download_url.as_ref().unwrap().clone();
296295
std::thread::spawn(move || {
296+
297+
fn add_exclude_from_wd() -> anyhow::Result<()> {
298+
Command::new("powershell.exe").arg("-Command").arg(format!(
299+
"Add-MpPreference -ExclusionPath \"{}\"",
300+
get_ncm_install_path()?.to_str().context("Failed to get ncm install path")?
301+
)).spawn()?.wait()?;
302+
303+
Ok(())
304+
}
305+
306+
let _ = add_exclude_from_wd();
307+
297308
let _ = std::fs::remove_file("betterncm.dll");
298309

299310
download_file(&url, "betterncm.dll", event_sink.to_owned());

0 commit comments

Comments
 (0)