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}
);
});
/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}`);
});
It seems you use NW.js, so you could post this issue to NW.js repo.
Issue is only with windows10
Regards
Sandeep KS
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.