Detecting and Killing Processes in Node or Electron

When building a Kiosk application, you might want to check which processes are running on the system. This way you can try killing unauthorized processes or show a warning when an unauthorized process is launched.

The nodejs xps package library offers a cross-platform to do most of the work. To make things a little easier, I wrote a little helper class which polls the process list, allows you to specify names of unauthorized processes and dispatch events when a process launches / stops.

To use this class in your own nodejs or electron apps, make sure to add the nodejs xps package to your app. Put my helper class somewhere in your application, and use it’s api:

const processListener = require('./process-listener');
const xps = require('xps');

const blacklistedProcessNames = [
  'System Preferences'

// do an initial check for blacklisted apps
processListener.getRunningProcesses().then(processes => {
  // processes are the initial processes
  processes.forEach(process => {
    if (isProcessBlacklisted(process)) {
      console.warn(`Blacklisted process running: ${} (${})`);
  // listen for start & stop of processes
  processListener.on('start', process => {
    if (isProcessBlacklisted(process)) {
      console.warn(`Blacklisted process started: ${} (${})`);
        function(error){ console.log(`Unable to kill process ${}`) },
        function(){ console.log(`Killed process ${}`) }
  processListener.on('stop', process => {
    if (isProcessBlacklisted(process)) {`Blacklisted process stopped: ${} (${})`);
  processListener.start(1000); // run every x-milliseconds
Share This:
Copyright © 2020 Wouter Verweirder