我正在为“在线表格注册”创建电子窗口应用程序。如果有人几乎没有关闭此应用程序,则立即自动运行.exe文件。请帮我解决一下这个。我们可以使用javascript吗?或电子提供了任何此类选择。
我们已经尝试过以下提到的代码,但是此功能根本无法正常工作。
require('electron-reload')(__dirname, {
electron: path.join(__dirname, 'node_modules', '.bin', 'electron'),
hardResetMethod: 'exit'
});
var exec = require('child_process').exec
exec(process.argv.join(' ')) // execute the command that was used to run the app
app.quit() // quit the current app
function setKeyValue () {
var regKey = new winreg({
hive: winreg.HKCU,
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
});
regKey.set('Your_Application_Name', winreg.REG_SZ, '"' + process.execPath + '"', function (err) {
if (!err) {
//notify user?
}
});
app.relaunch({ args: process.argv.slice(1).concat(['--relaunch']) })