Skip to content

Commit 79100b9

Browse files
committed
Add windowsHide: true to all spawn/spawnSync calls
Prevents the black console window from flashing on Windows whenever the app spawns a child process (Python scripts, pip, nvidia-smi, where). windowsHide: true suppresses the win32 CREATE_NEW_CONSOLE flag so no visible window appears — output is still captured via piped stdio.
1 parent a9ca20e commit 79100b9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

electron/main.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function getPythonPath() {
9090

9191
function findExecutable(name) {
9292
const cmd = process.platform === 'win32' ? 'where' : 'which';
93-
const r = spawnSync(cmd, [name], { encoding: 'utf8', timeout: 3000 });
93+
const r = spawnSync(cmd, [name], { encoding: 'utf8', timeout: 3000, windowsHide: true });
9494
if (r.status === 0 && r.stdout) return r.stdout.trim().split('\n')[0].trim();
9595
return null;
9696
}
@@ -261,7 +261,7 @@ async function findSystemPython() {
261261
const result = await new Promise((resolve, reject) => {
262262
const proc = spawn(shell, ['-l', '-c',
263263
"python3 -c 'import ssl,venv,sys; print(sys.executable)'"],
264-
{ timeout: 15000 });
264+
{ timeout: 15000, windowsHide: true });
265265
let out = '';
266266
proc.stdout?.on('data', d => out += d);
267267
proc.on('close', code => code === 0 ? resolve(out) : reject());
@@ -309,15 +309,15 @@ async function findSystemPython() {
309309

310310
for (const cand of candidates) {
311311
if (!cand || !fs.existsSync(cand)) continue;
312-
const r = spawnSync(cand, ['-c', 'import ssl, venv'], { timeout: 5000 });
312+
const r = spawnSync(cand, ['-c', 'import ssl, venv'], { timeout: 5000, windowsHide: true });
313313
if (r.status === 0) return cand;
314314
}
315315
return null;
316316
}
317317

318318
function detectCuda() {
319319
try {
320-
const r = spawnSync('nvidia-smi', [], { encoding: 'utf8', timeout: 10000 });
320+
const r = spawnSync('nvidia-smi', [], { encoding: 'utf8', timeout: 10000, windowsHide: true });
321321
if (r.status === 0) {
322322
const m = r.stdout.match(/CUDA Version:\s*(\d+)\.(\d+)/);
323323
if (m) return [parseInt(m[1]), parseInt(m[2])];
@@ -389,6 +389,7 @@ function runProcess(cmd) {
389389
cwd: outDir,
390390
env,
391391
stdio: ['ignore', 'pipe', 'pipe'],
392+
windowsHide: true,
392393
});
393394
activeProc = proc;
394395
proc.stdout.on('data', d => mainWindow?.webContents.send('process:data', d.toString('utf8')));
@@ -434,8 +435,7 @@ async function runInstaller(basePython, sendLog, sendDone) {
434435
const proc = spawn(cmd, args, {
435436
stdio: ['ignore', 'pipe', 'pipe'],
436437
env: { ...process.env, PYTHONUNBUFFERED: '1', PYTHONIOENCODING: 'utf-8', PYTHONUTF8: '1' },
437-
// On Windows use explicit shell for commands in PATH
438-
...(process.platform === 'win32' ? { shell: false } : {}),
438+
windowsHide: true,
439439
});
440440
installProc = proc;
441441
proc.stdout.on('data', d => sendLog(d.toString('utf8')));

0 commit comments

Comments
 (0)