16

I'm developing an App using the latest version of Electron-builder (using AutoUpadate).

Is there any way to know that the App is running for the first time after installation?

Ps: I have tried using electron-config but the user data files are not deleted after uninstall, and I needed to do some things with every installation (even if it's on the same machine).

Marcelo Romao
  • 163
  • 1
  • 6

2 Answers2

13

Check for the squirrel-firstrun flag:

var cmd = process.argv[1];

if (cmd == '--squirrel-firstrun') {
    // Running for the first time.
}

(you don't need to install anything for this to work)

Ref.

Joshua
  • 5,032
  • 2
  • 29
  • 45
1

Your app could, in case that it doesn't exist, write a folder/file (with filename based on a timestamp?).

When app starts, always look for the file. If there is no file, means its first time, do what you want and write file.

If there is a file means it's not the first time.


Don't know if there is something at Electron API!

oikonomopo
  • 4,025
  • 7
  • 44
  • 73
  • 1
    But if I uninstall the App, those file will not be delete, so, If the user reinstall the App, i will get a false check. (cause file will exists) – Marcelo Romao May 12 '17 at 14:17
  • I don't know, but you could install an app, check its folder structure, then uninstall and recheck the folder structure. Look which folder are missing! Then in such a folder write your file! Apply changes and check..Hope it helps! – oikonomopo May 12 '17 at 14:56