How to detect that the Electron application is running for the first time?

I am developing an application using the latest version of Electron-builder (using AutoUpadate).

Is there a way to find out that the application launches for the first time after installation?

Ps: I tried using the electronic configuration, but the user data files are not deleted after deletion, and I had to do something with each installation (even if it was on the same machine).

+5
source share
2 answers

Check the squirrel-firstrun checkbox:

var cmd = process.argv[1]; if (cmd == '--squirrel-firstrun') { // Running for the first time. } 

(you do not need to install anything for this)

Link

+3
source

Your application can, if it does not exist, write a folder / file (with a file name based on a timestamp?).

When the application starts, always look for the file. If the file is missing, then it is the first time, do what you want and write the file.

If there is a file, then this is not the first time.


I don’t know if there is anything in the Electron API!

0
source

Source: https://habr.com/ru/post/1267338/


All Articles