diff --git a/main.js b/main.js index 71bba56..f0077dc 100644 --- a/main.js +++ b/main.js @@ -3073,15 +3073,26 @@ ipcMain.handle("recheck-update", async () => { return { updateAvailable, currentVersion: app.getVersion() }; }); // One-click "Install & restart". Requires the silent pre-fetch to have -// finished (updateDownloadState === "ready"). Launches the setup with /S -// (skips the wizard; our nsis/installer.nsh's Ariadne prompt is bypassed -// too on upgrades because the Ariadne registry key is already present), -// then quits Theseus so the installer can overwrite it. When the installer -// finishes, the user re-launches Theseus and lands on the new version. +// finished (updateDownloadState === "ready"). +// +// CRITICAL — spawning the setup with just ["/S"] uninstalls Theseus but +// then FAILS to reinstall on our config (oneClick:false + perMachine:false +// + allowToChangeInstallationDirectory:true). In wizard mode NSIS expects +// UI for the install-path picker, and in silent mode with the registry +// path wiped by the just-run uninstaller, it exits without installing. +// Users hit this in 0.3.31: browser gone, nothing left. +// +// Fix: pass --updated alongside /S. electron-builder's NSIS template +// treats --updated as "this is an auto-update, reuse the existing install +// directory from registry, don't re-run the uninstaller". --force-run +// tells it to relaunch the app after install so the user isn't stranded +// even if the wizard-mode path somehow trips again. ipcMain.handle("install-update-now", () => { if (updateDownloadState !== "ready" || !updateDownloadPath) return false; try { - const p = spawn(updateDownloadPath, ["/S"], { detached: true, stdio: "ignore" }); + const p = spawn(updateDownloadPath, + ["--updated", "/S", "--force-run"], + { detached: true, stdio: "ignore" }); p.unref(); } catch (e) { console.warn("update spawn failed:", e?.message); return false; } // Give the child a moment to inherit our arguments before we exit.