【发布时间】:2022-01-05 10:37:20
【问题描述】:
启动外部文件或应用程序后是否可以退出主应用程序?
const child = require('child_process').execFile;
const fs = require('fs');
if (fs.existsSync(updateFile)) {
child(updateFile, function(err, data) { }); //start the update.exe
app.quit(); //quit the app
}
我正在尝试从
temp
目录打开我的应用程序
updater.exe
以安装新更新。由于某种原因,我无法使用
autoUpdater
。
updater.exe
是使用
C#.net
创建的,它只是在下载后用新文件替换旧文件,但在主应用程序仍在运行时我不能这样做。我正在考虑从
C# .net
到
Process
终止应用程序,但这对我来说感觉不太合适。
在
Electron-Node.js
中使用上面的代码,
updater.exe
在调用
app.quit()
后也会退出,因为它只是主应用程序的子应用程序。替代方法是什么?
PS:这只支持Windows。 Windows 10 和 11 更具体。
-
你看过
child_process.spawn()
吗?也许它的detached
选项接近你想要做的......