Process manipulation with Javascript

Asked

Viewed 290 times

1

I’d like to know how I give kill in a process running with javascript.

To do this with the cmd you must first list capture the PID and execute the command taskKill with the PID as follows:

netstat –ano | more
CTRL + C
taskKill.exe /F /PID 6676

I’d like to run it automatic by javascript.

  • You want to do this using a browser?

  • want to use to run and finaziar backend in an application . js

  • 2

    If you’re using Nodejs, there are a few ways, one I found is this process.kill(process.pid, 'SIGHUP');, no link https://nodejs.org/api/process.html#process_process_kill_pid_signal. But if you are running in the browser, unfortunately you cannot do this

  • Many use this https://www.npmjs.com/package/shelljslibrary

1 answer

0

You can kill the process by its name and even if there are several of it it will finish all, for example:

taskkill /im /f firefox.exe

The parameter /imdetermines a process name and parameter /f force the completion of the process.

In the example it would terminate all naming processes firefox.exe

In the case of linux there is the command kill or killall the first would pass the process pid or the second would pass the process name.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.