When I use the tasklist command with child_process, the stdout returns processes in Unicode string format that is not easily queryable.
Here is the code snippet:
var exec = require('child_process').exec;
...
exec('tasklist', function(err, stdout, stderr) {
...
});
An example part of the stdout output:
\r\nImage Name PID Session Name Session# Mem Usage\r\n========================= ======== ================ =========== ============\r\nSystem Idle Process 0 Services 0 8 K\r\nSystem 4 Services 0 3,900 K\r\nRegistry 148 Services 0 57,232 K\r\nsmss.exe 636 Services 0 444 K\r\ncsrss.exe 820 Services 0 3,604 K\r\nwininit.exe 716 Services 0 2,824 K\r\nservices.exe 8 Services 0 9,180 K\r\nlsass.exe...
Is there a way to retrieve the stdout output in JSON format?
I have tried various methods to convert from Unicode to JSON but have not found a simple solution yet.