[英]Nodejs run exe from full path | child_process
I have to start an exe file with the full path of the game.我必须启动一个包含游戏完整路径的 exe 文件。
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感谢您的帮助:D
Like Tomalak said in the commets, i had to use the path module, so i splitted the dir and the name of the game.就像 Tomalak 在 commets 中所说的那样,我必须使用 path 模块,所以我拆分了目录和游戏名称。 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});
You should go to the disk & game_path & game_name.exe (using exec of child_process).你应该 go 到磁盘 & game_path & game_name.exe(使用 child_process 的 exec)。
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());
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.