CheckMate
CheckMate

Reputation: 58

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

Upvotes: 0

Views: 1316

Answers (2)

sam fisher
sam fisher

Reputation: 11

You should go to the disk & game_path & game_name.exe (using exec of child_process).

Example:

let link = "e: & cd E:\GAMES\INSTALLED\Fable The Lost Chapters & Fable.exe"
let process = child_process.exec(link, function (err, data) {
    console.log(err)
    console.log(data.toString());
});

Upvotes: 1

CheckMate
CheckMate

Reputation: 58

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});

Upvotes: 1

Related Questions