I'm developing a native app using Node webkit. As usually everything goes with JS.
what i need is: i want to schedule a task using "schtask" command. so that i need to run it from JS code.
Is there any way to run commands from JavaScript code?? or any other alternative to set schedule tasks in windows from Java Script?
- Thanks in advance
if you are using node-webkit you can use node-modules like child_process.
Here is a sample code how to run a ls command.
var spawn = require('child_process').spawn, // requiring child_process
ls = spawn('ls', ['-l', '.']); // created a process for ls the arguments in []
ls.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
Here are the references
I found this answer in google.. It works PERFECT!
var spawn = require('child_process').spawn;
var cp = spawn(process.env.comspec, ['/c', 'command', '-arg1', '-arg2']);
cp.stdout.on("data", function(data) {
console.log(data.toString());
});
cp.stderr.on("data", function(data) {
console.error(data.toString());
});
Thanks for your guidence @Mritunjay :)