1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 08:13:30 +00:00
Files
MeshAgent/Debug/ChildProcessTest.js
2017-11-09 16:07:39 -08:00

27 lines
777 B
JavaScript

var child = require('child_process');
var childProcess = null;
if (process.platform == 'win32')
{
childProcess = child.execFile(process.env['windir'] + '\\system32\\cmd.exe', ['/c', 'dir'], OnChild);
}
else if (process.platform == 'linux')
{
childProcess = child.execFile('/bin/sh', ['sh', '-c', 'ls'], OnChild);
}
if (childProcess != null)
{
console.log('PID = ' + childProcess.pid);
childProcess.stdout.on('data', function (chunk) { console.log(chunk.toString()); });
childProcess.on('exit', function (code, sig) { console.log("Process Exited with code: " + code.toString()); });
}
//for (var envkey in process.env)
//{
// console.log("Environment Variable: [" + envkey + "] = " + process.env[envkey]);
//}
function OnChild(err, stdErr, stdOut)
{
}