Node: Close and exit event triggering on launching child process

Created on 9 Dec 2016  路  3Comments  路  Source: nodejs/node

  • Version : nwjs-v0.18.7-win-x64
  • Platform : Windows10 64 Bit
  • Subsystem : node web kit

I am using the following code to launch the system calculator application and i need an event which trigger on closing that calculator application,but event is triggering on launching the application itself
.its been last 3 days i am looking for this issue same and the code working fine if i try to open notepad application

const spawn = require('child_process').spawn;
const bat = spawn('cmd.exe', ['/c', 'calc.exe']);
bat.on('exit', (code) => {
alert(Child exited with code ${code});
});

child_process question windows

Most helpful comment

/to @nodejs/platform-windows

I don't think there is anything node can do about this. You are running cmd.exe, and the exit event fires when it exits.

You need to be googling for information on cmd.exe and calc.exe, to see if there is expression you can run that can cause cmd.exe to not exit until calc.exe has exited. There may or may not be, but that isn't a node API problem.

All 3 comments

/to @nodejs/platform-windows

I don't think there is anything node can do about this. You are running cmd.exe, and the exit event fires when it exits.

You need to be googling for information on cmd.exe and calc.exe, to see if there is expression you can run that can cause cmd.exe to not exit until calc.exe has exited. There may or may not be, but that isn't a node API problem.

Can't reproduce with Node.js 7.2.1 on Windows 7 and with this code:

const spawn = require('child_process').spawn;

const bat = spawn('cmd.exe', ['/c', 'calc.exe']);
bat.on('exit', (code) => {
  console.log(`Child exited with code ${code}`);
});

calc

It seems you use NW.js, so you could post this issue to NW.js repo.

Issue is only with windows10

Regards
Sandeep KS

Was this page helpful?
0 / 5 - 0 ratings