|
1 | 1 | use std::fs::{File, remove_file}; |
2 | 2 | use std::io::Write; |
3 | 3 | use std::error::Error; |
| 4 | +use std::os::windows::process::CommandExt; |
4 | 5 | use std::process::Command; |
5 | 6 | use std::{thread, time}; |
6 | 7 | use std::sync::{Arc, atomic}; |
7 | 8 | use slint::{SharedString, ToSharedString}; |
8 | 9 | use sysinfo::System; |
| 10 | +use windows_sys::Win32::System::Threading::CREATE_NO_WINDOW; |
9 | 11 | 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}}; |
10 | 12 |
|
11 | 13 | // Create new SetupData and saves it as JSON |
@@ -55,7 +57,7 @@ pub fn make_process_batch(status_text: SharedString, status_emoji: SharedString) |
55 | 57 | file.write_all(bat_message.as_bytes())?; |
56 | 58 |
|
57 | 59 | // 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()?; |
59 | 61 |
|
60 | 62 | // Check if the batch file executed successfully |
61 | 63 | if status.success() { |
@@ -92,7 +94,7 @@ pub fn set_default_status_batch() -> Result<(), Box<dyn Error>> { |
92 | 94 | file.write_all(bat_message.as_bytes())?; |
93 | 95 |
|
94 | 96 | // 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()?; |
96 | 98 |
|
97 | 99 | // Check if the batch file executed successfully |
98 | 100 | if status.success() { |
|
0 commit comments