Search code examples
node.jschild-process

Nodejs run exe from full path | child_process


I have to start an exe file with the full path of the game.

I have tried many combination command, the main goal is to exec the full path like this cause i have to iterate many different games.

var rainbow = "D:\\Games\\Tom Clancy's Rainbow Six Siege\\rainbowsix.exe"
child_process.exec(rainbow);

I know i can start the game in this way:

var path = "D:\\Games\\Tom Clancy's Rainbow Six Siege\\"; 

child_process.exec('rainbowsix.exe', {cwd: path});

But i have to run it only with the full path.

Thanks for any help:D


Solution

  • Like Tomalak said in the commets, i had to use the path module, so i splitted the dir and the name of the game. And than i had to add '\\\\' at the end of the line.

    var dirgame = path.dirname(id)+'\\\\';
    var namegame = path.basename(id);
    child_process.exec(namegame, {cwd: dirgame});