I am working on an electron test application for windows.
The goal is an auto launching application which displays a popup message everytime the windows user logs in.
Scenario:
npm start
to package my code. (index.js +
package.json).exe
which will popup my message. (so far so good, right?)CTRL + L ALT + DEL
if this is important) and sign in again to test the application.package.json
{
"name": "test",
"description": "",
"version": "0.0.1",
"main": "index.js",
"scripts": {
"test": "electron .",
"start": "electron-packager . Test --platform=win32 --arch=x64 --overwrite"
},
"author": "",
"license": "MIT",
"build": {
"appId": "com.test.test",
"win": {
"target": "NSIS"
}
},
"dependencies": {
"auto-launch": "^5.0.5"
},
"devDependencies": {
"electron": "latest",
"electron-packager": "^12.1.1"
}
}
index.js
const {app, dialog} = require("electron");
const AutoLaunch = require("auto-launch");
app.on("ready", function(){
dialog.showMessageBox({ message: "We are ready to take off! :-)", buttons: ["OK"] });
let autoLaunch = new AutoLaunch({
name: "test"
// path: app.getPath("exe")
}).isEnabled().then((isEnabled) => {
if (!isEnabled){
autoLaunch.enable();
dialog.showMessageBox({ message: "AutoLaunch enabled.", buttons: ["OK"] });
}
else dialog.showMessageBox({ message: "AutoLaunch already enabled.", buttons: ["OK"] });
});
app.quit();
});
Edit: Found a problem that prevents the package.json
being updated. A simple npm info
resulted in a completely unexpected output.
Wow, totally forgot about this question. The solution was following:
Update all dependencies. Make sure, that the path to the .html / .js file is absolute and correct.
An absolute path start with a /
For example /files/index.html
That's how it works!