diff --git a/electron-builder.yml b/electron-builder.yml index dd10e81a..751686cc 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -23,6 +23,7 @@ win: extraResources: - from: binaries/7z.exe - from: binaries/7z.dll + - from: resources/commonredist/** target: - nsis - portable diff --git a/resources/commonredist/dotNetFx40_Full_setup.exe b/resources/commonredist/dotNetFx40_Full_setup.exe new file mode 100644 index 00000000..384fb834 Binary files /dev/null and b/resources/commonredist/dotNetFx40_Full_setup.exe differ diff --git a/resources/commonredist/dxwebsetup.exe b/resources/commonredist/dxwebsetup.exe new file mode 100644 index 00000000..07ef6b81 Binary files /dev/null and b/resources/commonredist/dxwebsetup.exe differ diff --git a/resources/commonredist/install.bat b/resources/commonredist/install.bat new file mode 100644 index 00000000..05602898 --- /dev/null +++ b/resources/commonredist/install.bat @@ -0,0 +1,36 @@ +@echo off +:: Request admin privileges if not already elevated +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo Requesting administrative privileges... + powershell -Command "Start-Process '%~f0' -Verb RunAs" + exit +) + +:: Change to the script’s directory +cd /d "%~dp0" + +echo Installing prerequisites silently... + +:: Install .NET Framework 4.0 +if exist dotNetFx40_Full_setup.exe dotNetFx40_Full_setup.exe /q /norestart /log dotnet_install.log + +:: Install DirectX +if exist dxwebsetup.exe dxwebsetup.exe /Q + +:: Install OpenAL +if exist oalinst.exe oalinst.exe /silent + +:: Install Visual C++ Redistributables (2015-2019) +if exist vcredist_2015-2019_x64.exe vcredist_2015-2019_x64.exe /quiet /norestart +if exist vcredist_2015-2019_x86.exe vcredist_2015-2019_x86.exe /quiet /norestart + +:: Install older Visual C++ Redistributables +if exist vcredist_x64.exe vcredist_x64.exe /quiet /norestart +if exist vcredist_x86.exe vcredist_x86.exe /quiet /norestart + +:: Install XNA Framework 4.0 +if exist xnafx40_redist.msi msiexec /i xnafx40_redist.msi /quiet /norestart + +echo Installation complete! +pause \ No newline at end of file diff --git a/resources/commonredist/oalinst.exe b/resources/commonredist/oalinst.exe new file mode 100644 index 00000000..0b61822d Binary files /dev/null and b/resources/commonredist/oalinst.exe differ diff --git a/resources/commonredist/vcredist_2015-2019_x64.exe b/resources/commonredist/vcredist_2015-2019_x64.exe new file mode 100644 index 00000000..7476d75a Binary files /dev/null and b/resources/commonredist/vcredist_2015-2019_x64.exe differ diff --git a/resources/commonredist/vcredist_2015-2019_x86.exe b/resources/commonredist/vcredist_2015-2019_x86.exe new file mode 100644 index 00000000..e1fe7cf7 Binary files /dev/null and b/resources/commonredist/vcredist_2015-2019_x86.exe differ diff --git a/resources/commonredist/vcredist_x64.exe b/resources/commonredist/vcredist_x64.exe new file mode 100644 index 00000000..6ae64fb4 Binary files /dev/null and b/resources/commonredist/vcredist_x64.exe differ diff --git a/resources/commonredist/vcredist_x86.exe b/resources/commonredist/vcredist_x86.exe new file mode 100644 index 00000000..57e15c0b Binary files /dev/null and b/resources/commonredist/vcredist_x86.exe differ diff --git a/resources/commonredist/xnafx40_redist.msi b/resources/commonredist/xnafx40_redist.msi new file mode 100644 index 00000000..42bbb26c Binary files /dev/null and b/resources/commonredist/xnafx40_redist.msi differ diff --git a/src/main/events/index.ts b/src/main/events/index.ts index 9ccf24c8..25d4b941 100644 --- a/src/main/events/index.ts +++ b/src/main/events/index.ts @@ -39,6 +39,7 @@ import "./misc/show-open-dialog"; import "./misc/get-features"; import "./misc/show-item-in-folder"; import "./misc/get-badges"; +import "./misc/install-commonredist"; import "./torrenting/cancel-game-download"; import "./torrenting/pause-game-download"; import "./torrenting/resume-game-download"; diff --git a/src/main/events/misc/install-commonredist.ts b/src/main/events/misc/install-commonredist.ts new file mode 100644 index 00000000..bce9c4cf --- /dev/null +++ b/src/main/events/misc/install-commonredist.ts @@ -0,0 +1,26 @@ +import { app } from "electron"; +import path from "node:path"; +import cp from "node:child_process"; +import { registerEvent } from "../register-event"; +import { logger } from "@main/services"; + +const installScriptPath = app.isPackaged + ? path.join(process.resourcesPath, "commonredist", "install.bat") + : path.join( + __dirname, + "..", + "..", + "resources", + "commonredist", + "install.bat" + ); + +const installCommonRedist = async (_event: Electron.IpcMainInvokeEvent) => { + cp.execFile(installScriptPath, (error) => { + if (error) { + logger.error(error); + } + }); +}; + +registerEvent("installCommonRedist", installCommonRedist); diff --git a/src/preload/index.ts b/src/preload/index.ts index 5f90ca19..63f77dcf 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -295,6 +295,7 @@ contextBridge.exposeInMainWorld("electron", { ipcRenderer.invoke("showItemInFolder", path), getFeatures: () => ipcRenderer.invoke("getFeatures"), getBadges: () => ipcRenderer.invoke("getBadges"), + installCommonRedist: () => ipcRenderer.invoke("installCommonRedist"), platform: process.platform, /* Auto update */ diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 0ae28e2f..9bdf73e1 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -234,6 +234,7 @@ declare global { showItemInFolder: (path: string) => Promise; getFeatures: () => Promise; getBadges: () => Promise; + installCommonRedist: () => Promise; platform: NodeJS.Platform; /* Auto update */ diff --git a/src/renderer/src/pages/settings/settings-general.tsx b/src/renderer/src/pages/settings/settings-general.tsx index e2cf2971..46662358 100644 --- a/src/renderer/src/pages/settings/settings-general.tsx +++ b/src/renderer/src/pages/settings/settings-general.tsx @@ -185,6 +185,10 @@ export function SettingsGeneral() { }) } /> + + ); }