This commit is contained in:
2025-09-26 17:05:42 +08:00
parent fcc5755dad
commit 89f600fa11
5 changed files with 62 additions and 33 deletions

View File

@@ -278,6 +278,26 @@ ipcMain.handle('install-update', async () => {
return { success: false, error: '更新文件不存在' };
}
const appDir = dirname(process.execPath);
const helperPath = join(appDir, 'update-helper.bat');
const appAsarPath = join(process.resourcesPath, 'app.asar');
if (!existsSync(helperPath)) {
return { success: false, error: '更新助手不存在' };
}
const vbsPath = join(app.getPath('temp'), 'update-install.vbs');
const vbsContent = `Set WshShell = CreateObject("WScript.Shell")
WshShell.Run Chr(34) & "${helperPath.replace(/\\/g, '\\\\')}" & Chr(34) & " " & Chr(34) & "${appAsarPath.replace(/\\/g, '\\\\')}" & Chr(34) & " " & Chr(34) & "${updateFilePath.replace(/\\/g, '\\\\')}" & Chr(34) & " " & Chr(34) & "${process.execPath.replace(/\\/g, '\\\\')}" & Chr(34), 0, False`;
require('fs').writeFileSync(vbsPath, vbsContent);
spawn('wscript.exe', [vbsPath], {
detached: true,
stdio: 'ignore',
shell: false
});
setTimeout(() => {
downloadedFilePath = null;
app.quit();