1
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user