From c92db733034a549e53ebf2c83aaea828ca61697a Mon Sep 17 00:00:00 2001 From: Rémy Raes Date: Sun, 23 Jan 2022 20:05:37 +0100 Subject: fix: Finding Windows game folder (#55) --- src/extras/findgame.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/extras') diff --git a/src/extras/findgame.js b/src/extras/findgame.js index 426d2e3..f2d7be1 100644 --- a/src/extras/findgame.js +++ b/src/extras/findgame.js @@ -6,7 +6,7 @@ const { app } = require("electron"); const util = require("util"); const exec = util.promisify(require("child_process").exec); -module.exports = () => { +module.exports = async () => { let gamepath = ""; // Autodetect path @@ -14,13 +14,13 @@ module.exports = () => { // Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2\ if (process.platform == "win32") { try { - exec("Get-Item -Path Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\", {"shell":"powershell.exe"}, (err, stdout) => { - gamepath = stdout.split('\n') - .filter(r => r.indexOf("Install Dir") !== -1)[0] - .replace(/\s+/g,' ') - .trim() - .replace("Install Dir : ",""); - }); + const {stdout} = await exec("Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\ -Name \"Install Dir\"", {"shell":"powershell.exe"}); + + const gamepath = stdout.split('\n') + .filter(r => r.indexOf("Install Dir") !== -1)[0] + .replace(/\s+/g,' ') + .trim() + .replace("Install Dir : ",""); if (gamepath) {return gamepath} } catch (err) {} -- cgit v1.2.3