coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.78k stars 357 forks source link

Error on wincmd.kill - Process can only be terminated forcefully (with /F option). #250

Closed de-mim-1974 closed 4 years ago

de-mim-1974 commented 4 years ago

I like your package, thank you for that!

If I execute the following on node-windows@1.0.0-beta.1

wincmd.kill(11624, function (msg) {
   console.log('result: ' + msg)
});

I get the following output:

result: Error: Command failed: taskkill /PID 11624 ERROR: The process with PID 11624 could not be terminated. Reason: This process can only be terminated forcefully (with /F option).

Is there a way to execute the command with the /F option?

coreybutler commented 4 years ago

Thanks, I'm glad the module is proving useful for you.

To answer your question, yes, the kill command has an optional boolean attribute:

wincmd.kill(11624, true, function (msg) {
   console.log('result: ' + msg)
})

See https://github.com/coreybutler/node-windows/blob/master/lib/cmd.js#L28-L38 for the implementation.