Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

376
Vistas
Electron-Node.js Quit app after launching external app or file

Is it possible to quit the main application after launching an external file or app?

const child = require('child_process').execFile;
const fs = require('fs');
if (fs.existsSync(updateFile)) {
   child(updateFile, function(err, data) { }); //start the update.exe
   app.quit(); //quit the app
}

I'm trying to open my app updater.exe from the temp directory to install the new update. I cant use the autoUpdater for some reason.

The updater.exe is created using C#.net and it simply replaces the old files with the new ones after download, but I can't do that while the main application is still running. I'm thinking to kill the application from the C# .net through Process but it doesn't feel so right for me.

Using the code above in Electron-Node.js the updater.exe also quit after calling the app.quit() since it's just a child of the main application. What is the alternative method?

PS: This only supports Windows. Windows 10 and 11 to be more specific.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Thanks to @AlexanderLeither, it turns out that an option detached is available in child_process.spawn().

This makes it possible for the child process to continue running after the parent exits.

const child = require('child_process').spawn;
const subprocess = child(updateFile, {
  detached: true,  //Continue running after the parent exits.
  stdio: 'ignore'  
});  
subprocess.unref(); //To prevent the parent from waiting for a given subprocess to exit
app.quit();

Also, for some reason, there are four electron processes when I tried to look in Taskmanager. I had to kill it using Process in my C# .net to avoid IO errors when replacing files.

while(true) { //don't stop killing untill no more process with the same name.
    try {
        Process[] process = Process.GetProcessesByName("TestProject"); //TestProject is the name of my current project and is in the TaskManager
        if(process.Length < 1) break; //if the process doesn't exist then break this loop. 
        process[0].Kill(); //if the process exist, kill it
        process[0].WaitForExit(); //wait until the process exits
    } catch(Exception) {
        //this will throw an exception if the same process is trying to kill while it is being kill, that's okay.
    }
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda