Unable to execute child_process.exec() when path has spaces

To open a path than contains spaces, you must replace with a double backslash.

In your code you escaped the space character:

"\ "

What you need to do is escape the backslash character so it makes it into the output string:

"\\ "

Try this:

var path = __dirname + '/folder to open/'; 

// Notice the double-backslashes on this following line
path = path.replace(/ /g, '\\ ');

require("child_process").exec("start " + path);

Well, I fixed it.

Or something like it.

Instead of using

"start " + path

I used

"%SystemRoot%\\explorer.exe \"" + path + "\""

Notice the quotes and the forward slashes.