fix(windows): suppress background console windows
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled

This commit is contained in:
Admin 2026-09-25 23:35:30 +00:00
parent 96939380b0
commit 8915fca840
6 changed files with 32 additions and 13 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@fieldlens/print", "name": "@fieldlens/print",
"version": "0.1.23", "version": "0.1.24",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {

View File

@ -1,6 +1,6 @@
[package] [package]
name = "fieldlens-print" name = "fieldlens-print"
version = "0.1.23" version = "0.1.24"
description = "FieldLens print-stream barcode capture companion" description = "FieldLens print-stream barcode capture companion"
authors = ["Arrowstack"] authors = ["Arrowstack"]
edition = "2021" edition = "2021"

View File

@ -11,6 +11,8 @@ use base64::{engine::general_purpose::STANDARD as BASE64_STANDARD, Engine as _};
use parking_lot::Mutex; use parking_lot::Mutex;
use serde_json::Value; use serde_json::Value;
use std::{fs, path::{Path, PathBuf}, time::SystemTime}; use std::{fs, path::{Path, PathBuf}, time::SystemTime};
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
use tauri::{AppHandle, Manager, State}; use tauri::{AppHandle, Manager, State};
use capture::CaptureRuntime; use capture::CaptureRuntime;
@ -158,7 +160,12 @@ fn build_self_test_pdf() -> Vec<u8> {
fn debug_command_check(name: &str) -> DebugCheck { fn debug_command_check(name: &str) -> DebugCheck {
#[cfg(target_os = "windows")] #[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"))] #[cfg(not(target_os = "windows"))]
let result = std::process::Command::new("sh") let result = std::process::Command::new("sh")

View File

@ -1,5 +1,8 @@
use std::process::Command; use std::process::Command;
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
#[cfg(any(target_os = "windows", target_os = "linux"))] #[cfg(any(target_os = "windows", target_os = "linux"))]
use std::fs; use std::fs;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@ -18,6 +21,15 @@ const TEST_VIRTUAL_PRINTER_QUEUE: &str = "FieldLens-Test-Capture";
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
const TEST_CAPTURE_DEVICE_URI: &str = "socket://127.0.0.1:9101"; const TEST_CAPTURE_DEVICE_URI: &str = "socket://127.0.0.1:9101";
const WINDOWS_PORT_NAME: &str = "FieldLensPrint-9100"; 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")] #[cfg(target_os = "linux")]
const FIELDLENS_CUPS_SPOOL_DIR: &str = "/var/lib/fieldlens-print/capture"; const FIELDLENS_CUPS_SPOOL_DIR: &str = "/var/lib/fieldlens-print/capture";
@ -325,8 +337,8 @@ $items = @(
$items | ConvertTo-Json -Compress $items | ConvertTo-Json -Compress
"#; "#;
let output = Command::new("powershell") let output = hidden_windows_command("powershell.exe")
.args(["-NoProfile", "-NonInteractive", "-Command", script]) .args(["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", script])
.output() .output()
.context("query Windows printers")?; .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 path = ps_quote(&script_path.to_string_lossy());
let elevated = format!( 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") let status = hidden_windows_command("powershell.exe")
.args(["-NoProfile", "-Command", &elevated]) .args(["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", &elevated])
.status() .status()
.context("launch elevated Windows printer setup")?; .context("launch elevated Windows printer setup")?;
@ -440,10 +452,10 @@ if (Get-PrinterPort -Name $portName -ErrorAction SilentlyContinue) {{
fs::write(&script_path, script)?; fs::write(&script_path, script)?;
let path = ps_quote(&script_path.to_string_lossy()); let path = ps_quote(&script_path.to_string_lossy());
let elevated = format!( 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") let status = hidden_windows_command("powershell.exe")
.args(["-NoProfile", "-Command", &elevated]) .args(["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", &elevated])
.status()?; .status()?;
let _ = fs::remove_file(&script_path); let _ = fs::remove_file(&script_path);

View File

@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "FieldLens Print", "productName": "FieldLens Print",
"version": "0.1.23", "version": "0.1.24",
"identifier": "dev.arrowstack.fieldlens.print", "identifier": "dev.arrowstack.fieldlens.print",
"build": { "build": {
"beforeDevCommand": "npm run dev", "beforeDevCommand": "npm run dev",

View File

@ -142,7 +142,7 @@ let config: AppConfig
let jobs: Job[] = [] let jobs: Job[] = []
let status: Status = { running: false, mode: 'raw-proxy', pending: 0, jobs: 0 } let status: Status = { running: false, mode: 'raw-proxy', pending: 0, jobs: 0 }
let loginTimer: number | undefined let loginTimer: number | undefined
let currentVersion = '0.1.23' let currentVersion = '0.1.24'
let bundleType: BundleType | null = null let bundleType: BundleType | null = null
let availableUpdate: Update | null = null let availableUpdate: Update | null = null
let availableManualUpdate: ManualUpdate | null = null let availableManualUpdate: ManualUpdate | null = null