halfmagic
1/9/2020 - 3:21 AM

windows kill process by name

const wincmd = require('node-windows')
const find = require('find-process')
find('name', 'LogiCapture.exe', true)
  .then(function (process) {

    console.log(process[0].pid)
    wincmd.kill(process[0].pid, 'SIGKILL', function(){
              console.log('LogiCapture.exe', 'process killed')
            })
  });
const psList = require('ps-list')
const wincmd = require('node-windows')

(async () => { targetProcessList = await psList() })();

(async () => {
    targetProcessList.forEach(async(process)=>{
      await wincmd.kill(process.pid, 'SIGKILL', function(){
        log.log(process.pid, process.name, 'process killed')
      })
    })
})();