Reputation: 2358
I am trying to open files using node js child processes.
I am using execFile command for that.
my code is as follows:
execFile("C:/Program Files (x86)/Windows Media Player/wmplayer.exe",["a.mp4"] ,(err, stdout, stderr) => {
console.log(stdout, stderr, err)
}).unref()
However in cmd just a.mp4
command works.
I tried the following:
execFile("",["a.mp4"] ,(err, stdout, stderr) => {
console.log(stdout, stderr, err)
}).unref()
or
execFile("a.mp4",(err, stdout, stderr) => {
console.log(stdout, stderr, err)
}).unref()
and both do not work.
Is there a way i could run a.mp4
without providing the application path to run the binary ?
Upvotes: 1
Views: 1545
Reputation: 2358
This can actually be done using exec.
execFile expects an executable (.exe) the first argument.
Where as exec blindly executes the command.
exec('"a.mp4"', (stdout, stderr, err)=>{
console.log(stdout, stderr, err)
}
This will work fine.
Upvotes: 1