Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can i use nodejs to quit another application?

Can i use nodejs to quit / exit a completely different application or program, for example paint.exe?

I’ve been trying a lot of different search queries for this and i find it strange that this question has never been asked before (it seems to me)

Thank you in advance

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes you can,

First you need to determine the PID of the process.
Then you can kill it with process.kill(pid)

To find the PID, I would recommend this ps-list npm package. It has a psList function which lists the active processes.

import psList from 'ps-list';

async function killProcess(name) {
    const processes = await psList()
    const match = processes.find(p => p.name === name);
    if (match) process.kill(match.pid)
}

killProcess('mspaint.exe');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading