I want to close chrome application on windows through nodejs.
Here what I did :
var ps = require('ps-node');
ps.lookup({ pid: 8092 }, function(err, resultList ) {
if (err) {
throw new Error( err );
}
var process = resultList[ 0 ];
if( process ){
console.log( 'PID: %s, COMMAND: %s, ARGUMENTS: %s', process.pid, process.command, process.arguments );
//process.kill(8092)
}
else {
console.log( 'No such process found!' );
}
});
I am not able to kill the process. Can anyone suggest a way to do it. I tried process.exit() process.kill process.abort, but nothing worked for me. It would be great if you help me out.
just use ps.kill
ps.kill('8092', function( err ) {
if (err) {
throw new Error( err );
}
else {
console.log( 'Process with pid 8092 has been killed!');
}
});
you can check the documentation for more info