diff options
author | Rémy Raes <raes.remy@gmail.com> | 2022-01-23 20:05:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-23 20:05:37 +0100 |
commit | c92db733034a549e53ebf2c83aaea828ca61697a (patch) | |
tree | ca3423c74b938dc038edb544722bc3bf83c03fd3 /src | |
parent | 837008b5baf2233c2c5e900e4f55a2ecf52bef1b (diff) | |
download | Viper-c92db733034a549e53ebf2c83aaea828ca61697a.tar.gz Viper-c92db733034a549e53ebf2c83aaea828ca61697a.zip |
fix: Finding Windows game folder (#55)
Diffstat (limited to 'src')
-rw-r--r-- | src/extras/findgame.js | 16 | ||||
-rw-r--r-- | src/utils.js | 4 |
2 files changed, 10 insertions, 10 deletions
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) {} diff --git a/src/utils.js b/src/utils.js index bc0f66c..a2c61d4 100644 --- a/src/utils.js +++ b/src/utils.js @@ -136,8 +136,8 @@ async function setpath(win) { ipcMain.emit("newpath", null, settings.gamepath); } - let gamepath = findgame(); - if (findgame()) { + let gamepath = await findgame(); + if (gamepath) { setGamepath(gamepath); return; } |