diff --git a/package.json b/package.json index 4953653..222e2fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fieldlens/print", - "version": "0.1.23", + "version": "0.1.24", "private": true, "type": "module", "scripts": { diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 63b64cb..45efea6 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fieldlens-print" -version = "0.1.23" +version = "0.1.24" description = "FieldLens print-stream barcode capture companion" authors = ["Arrowstack"] edition = "2021" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d0de0b5..43274de 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -11,6 +11,8 @@ use base64::{engine::general_purpose::STANDARD as BASE64_STANDARD, Engine as _}; use parking_lot::Mutex; use serde_json::Value; use std::{fs, path::{Path, PathBuf}, time::SystemTime}; +#[cfg(target_os = "windows")] +use std::os::windows::process::CommandExt; use tauri::{AppHandle, Manager, State}; use capture::CaptureRuntime; @@ -158,7 +160,12 @@ fn build_self_test_pdf() -> Vec { fn debug_command_check(name: &str) -> DebugCheck { #[cfg(target_os = "windows")] - let result = std::process::Command::new("where").arg(name).output(); + let result = { + const CREATE_NO_WINDOW: u32 = 0x08000000; + let mut command = std::process::Command::new("where.exe"); + command.creation_flags(CREATE_NO_WINDOW); + command.arg(name).output() + }; #[cfg(not(target_os = "windows"))] let result = std::process::Command::new("sh") diff --git a/src-tauri/src/printers.rs b/src-tauri/src/printers.rs index 751d30c..b271f6b 100644 --- a/src-tauri/src/printers.rs +++ b/src-tauri/src/printers.rs @@ -1,5 +1,8 @@ use std::process::Command; +#[cfg(target_os = "windows")] +use std::os::windows::process::CommandExt; + #[cfg(any(target_os = "windows", target_os = "linux"))] use std::fs; #[cfg(target_os = "linux")] @@ -18,6 +21,15 @@ const TEST_VIRTUAL_PRINTER_QUEUE: &str = "FieldLens-Test-Capture"; #[cfg(target_os = "linux")] const TEST_CAPTURE_DEVICE_URI: &str = "socket://127.0.0.1:9101"; const WINDOWS_PORT_NAME: &str = "FieldLensPrint-9100"; +#[cfg(target_os = "windows")] +const CREATE_NO_WINDOW: u32 = 0x08000000; + +#[cfg(target_os = "windows")] +fn hidden_windows_command(program: &str) -> Command { + let mut command = Command::new(program); + command.creation_flags(CREATE_NO_WINDOW); + command +} #[cfg(target_os = "linux")] const FIELDLENS_CUPS_SPOOL_DIR: &str = "/var/lib/fieldlens-print/capture"; @@ -325,8 +337,8 @@ $items = @( $items | ConvertTo-Json -Compress "#; - let output = Command::new("powershell") - .args(["-NoProfile", "-NonInteractive", "-Command", script]) + let output = hidden_windows_command("powershell.exe") + .args(["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", script]) .output() .context("query Windows printers")?; @@ -397,11 +409,11 @@ if ($null -ne $targetConfig -and $targetConfig.PrintTicketXML) {{ let path = ps_quote(&script_path.to_string_lossy()); let elevated = format!( - "$p = Start-Process powershell -Verb RunAs -Wait -PassThru -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-File','{path}','-TargetPrinter','{target}'); exit $p.ExitCode" + "$p = Start-Process -FilePath powershell.exe -Verb RunAs -WindowStyle Hidden -Wait -PassThru -ArgumentList @('-NoProfile','-NonInteractive','-WindowStyle','Hidden','-ExecutionPolicy','Bypass','-File','{path}','-TargetPrinter','{target}'); exit $p.ExitCode" ); - let status = Command::new("powershell") - .args(["-NoProfile", "-Command", &elevated]) + let status = hidden_windows_command("powershell.exe") + .args(["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", &elevated]) .status() .context("launch elevated Windows printer setup")?; @@ -440,10 +452,10 @@ if (Get-PrinterPort -Name $portName -ErrorAction SilentlyContinue) {{ fs::write(&script_path, script)?; let path = ps_quote(&script_path.to_string_lossy()); let elevated = format!( - "$p = Start-Process powershell -Verb RunAs -Wait -PassThru -ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-File','{path}'); exit $p.ExitCode" + "$p = Start-Process -FilePath powershell.exe -Verb RunAs -WindowStyle Hidden -Wait -PassThru -ArgumentList @('-NoProfile','-NonInteractive','-WindowStyle','Hidden','-ExecutionPolicy','Bypass','-File','{path}'); exit $p.ExitCode" ); - let status = Command::new("powershell") - .args(["-NoProfile", "-Command", &elevated]) + let status = hidden_windows_command("powershell.exe") + .args(["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", &elevated]) .status()?; let _ = fs::remove_file(&script_path); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 379f24f..e49ff91 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "FieldLens Print", - "version": "0.1.23", + "version": "0.1.24", "identifier": "dev.arrowstack.fieldlens.print", "build": { "beforeDevCommand": "npm run dev", diff --git a/src/main.ts b/src/main.ts index 93ecec6..7b1bd99 100644 --- a/src/main.ts +++ b/src/main.ts @@ -142,7 +142,7 @@ let config: AppConfig let jobs: Job[] = [] let status: Status = { running: false, mode: 'raw-proxy', pending: 0, jobs: 0 } let loginTimer: number | undefined -let currentVersion = '0.1.23' +let currentVersion = '0.1.24' let bundleType: BundleType | null = null let availableUpdate: Update | null = null let availableManualUpdate: ManualUpdate | null = null