fixed windows update installer

pull/1705/head
antelle 2021-01-10 00:14:28 +01:00
parent fddf62409a
commit bd882d0e17
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 14 additions and 2 deletions

View File

@ -41,12 +41,24 @@ function installDarwinUpdate(updateFilePath) {
}
function installWin32Update(updateFilePath) {
// spawn doesn't work on Windows in this case because of UAC
// exec doesn't work if KeeWeb is killed immediately
// so we write our command to a script and launch it
const appDir = path.dirname(electron.app.getPath('exe'));
spawnDetached(updateFilePath, [`/U1`, `/D=${appDir}`]);
updateFilePath = updateFilePath.replace(/ /g, '\\ ');
const updateCommand = `${updateFilePath} /U1 /D=${appDir}`;
const tempPath = path.join(electron.app.getPath('temp'), 'KeeWeb');
const updateLauncherScriptPath = path.join(tempPath, 'update-keeweb.cmd');
fs.writeFileSync(updateLauncherScriptPath, updateCommand);
spawnDetached(updateLauncherScriptPath);
}
function spawnDetached(command, args) {
const ps = spawn(command, args, { detached: true });
const ps = spawn(command, args || [], { detached: true });
ps.unref();
}