Skip to content

Commit 694be5b

Browse files
Fix cmd problems
1 parent a973e63 commit 694be5b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ slint = "1.12.1"
1212
serde = { version = "1.0.104", features = ["derive"] }
1313
serde_json = "1.0.140"
1414
sysinfo = "0.36.0"
15+
windows-sys = { version = "0.52", features = ["Win32_System_Threading"] }
1516

1617
[build-dependencies]
1718
slint-build = "1.12.1"

src/core_logic.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use std::fs::{File, remove_file};
22
use std::io::Write;
33
use std::error::Error;
4+
use std::os::windows::process::CommandExt;
45
use std::process::Command;
56
use std::{thread, time};
67
use std::sync::{Arc, atomic};
78
use slint::{SharedString, ToSharedString};
89
use sysinfo::System;
10+
use windows_sys::Win32::System::Threading::CREATE_NO_WINDOW;
911
use crate::{app_data::{SetupData, ProcessData, PROCESSES_DATA_FILE_NAME, SETUP_FILE_NAME, STATUS_LOGIC_BATCH_FILE_NAME, DEFAULT_STATUS_BATCH_FILE_NAME}, json_utils::{write_setup_data_to_json, read_setup_data_from_json}};
1012

1113
// Create new SetupData and saves it as JSON
@@ -55,7 +57,7 @@ pub fn make_process_batch(status_text: SharedString, status_emoji: SharedString)
5557
file.write_all(bat_message.as_bytes())?;
5658

5759
// Run the batch file using cmd
58-
let status = Command::new("cmd").args(["/C", STATUS_LOGIC_BATCH_FILE_NAME]).status()?;
60+
let status = Command::new("cmd").args(["/C", STATUS_LOGIC_BATCH_FILE_NAME]).creation_flags(CREATE_NO_WINDOW).status()?;
5961

6062
// Check if the batch file executed successfully
6163
if status.success() {
@@ -92,7 +94,7 @@ pub fn set_default_status_batch() -> Result<(), Box<dyn Error>> {
9294
file.write_all(bat_message.as_bytes())?;
9395

9496
// Run the batch file using cmd
95-
let status = Command::new("cmd").args(["/C", DEFAULT_STATUS_BATCH_FILE_NAME]).status()?;
97+
let status = Command::new("cmd").creation_flags(CREATE_NO_WINDOW).args(["/C", DEFAULT_STATUS_BATCH_FILE_NAME]).status()?;
9698

9799
// Check if the batch file executed successfully
98100
if status.success() {

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![windows_subsystem = "windows"]
2+
13
mod ui_logic;
24
mod core_logic;
35
mod json_utils;

0 commit comments

Comments
 (0)