diff --git a/src/main/events/library/open-game.ts b/src/main/events/library/open-game.ts index 20ac34b9..054a7cb5 100644 --- a/src/main/events/library/open-game.ts +++ b/src/main/events/library/open-game.ts @@ -2,10 +2,9 @@ import { gameRepository } from "@main/repository"; import { registerEvent } from "../register-event"; import { shell } from "electron"; -import { exec } from "child_process"; +import { spawn } from "child_process"; import { parseExecutablePath } from "../helpers/parse-executable-path"; import { parseLaunchOptions } from "../helpers/parse-launch-options"; -import { logger } from "@main/services"; const openGame = async ( _event: Electron.IpcMainInvokeEvent, @@ -15,23 +14,15 @@ const openGame = async ( ) => { const parsedPath = parseExecutablePath(executablePath); const parsedParams = parseLaunchOptions(launchOptions); - const executeCommand = `"${parsedPath}" ${parsedParams}`; - await gameRepository.update({ id: gameId }, { executablePath: parsedPath }); + await gameRepository.update({ id: gameId }, { executablePath: parsedPath, launchOptions }); if (process.platform === "linux" || process.platform === "darwin") { shell.openPath(parsedPath); } if (process.platform === "win32") { - exec(executeCommand.trim(), (err) => { - if (err) { - logger.error( - `Error opening game #${gameId} with command ${executeCommand}`, - err - ); - } - }); + spawn(parsedPath, parsedParams, { shell: false }); } }; diff --git a/src/renderer/src/pages/game-details/modals/game-options-modal.tsx b/src/renderer/src/pages/game-details/modals/game-options-modal.tsx index ad036003..4fed0de1 100644 --- a/src/renderer/src/pages/game-details/modals/game-options-modal.tsx +++ b/src/renderer/src/pages/game-details/modals/game-options-modal.tsx @@ -29,7 +29,7 @@ export function GameOptionsModal({ const [showDeleteModal, setShowDeleteModal] = useState(false); const [showRemoveGameModal, setShowRemoveGameModal] = useState(false); - const [launchOptions, setLaunchOptions] = useState(""); + const [launchOptions, setLaunchOptions] = useState(game.launchOptions ?? ""); const { removeGameInstaller,