i using appjs , want execute command open folder.
what have
var path = __dirname + '/folder open/'; // path = c:\program files\myapplication/folder open/ require("child_process").exec("start " + path);
error
could not find file c:\program
what tried
i tried escape spaces, didn't work.
var path = __dirname + '/folder open/'; path = path.replace(' ', '\ '); // path = c:\program files\myapplication/folder open/ require("child_process").exec("start " + path);
when put path between quotes, no folder opened, prompt.
var path = "\"" + __dirname + "/folder open/\""; path = path.replace(' ', '\ '); // path = "c:\program files\myapplication/folder open/" require("child_process").exec("start " + path);
related bug https://github.com/isaacs/npm/pull/2479
does has fix or workaround?
to open path contains spaces, must replace double backslash.
in code escaped space character:
"\ "
what need escape backslash character makes output string:
"\\ "
try this:
var path = __dirname + '/folder open/'; // notice double-backslashes on following line path = path.replace(/ /g, '\\ '); require("child_process").exec("start " + path);
Comments
Post a Comment