js run powershell script code example
Example 1: powershell script run
./myscript.ps1
c:/scripts/myscript.ps1
&"C:/my path with space/myscript.ps1"
Example 2: javascript execute powershell script
var spawn = require("child_process").spawn,child;
child = spawn("powershell.exe",["c:\\temp\\helloworld.ps1"]);
child.stdout.on("data",function(data){
console.log("Powershell Data: " + data);
});
child.stderr.on("data",function(data){
console.log("Powershell Errors: " + data);
});
child.on("exit",function(){
console.log("Powershell Script finished");
});
child.stdin.end();