1

I created an exe with NSIS that installs my application, but if the application is already running, it gets updated at startup.

It seems this simplest way to achieve this is by added a registry entry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

My entry looks like this:

Value name: InstallRUS
Value data: cmd /C "C:\Location\of\my\program.exe /S"

This executable simply copies files to a directory and runs a script to register the app as a windows service.

If I restart windows, it runs twice, the first time in silent mode, and the second time it seems to ignore the silent flag.

If I log out and log back in, it's correctly ran once in silent mode.

This leads to the conclusion that the task is ran at windows startup and login, yet the documentation states :

Run and RunOnce registry keys cause programs to run each time that a user logs on...By default, the value of a RunOnce key is deleted before the command line is run.

Does windows starting up counts as "user login"?

Why is the entry not deleted after the first run?

How can I fix this?

Why is windows lying to me?

Note:

  1. I'm using Windows 7 Professional x32
  2. Seems to be related to this: Windows Registry RunOnce Loop but I am not writing to the registry
Community
  • 1
  • 1
Ian2thedv
  • 2,691
  • 2
  • 26
  • 47
  • Maybe it is related to "cmd /C". What happens if you take that out and set Value Data to "C:\Location\of\my\program.exe /S"? – David Ching Mar 11 '15 at 15:57
  • Sounds like a bug in your program. But if you add some basic diagnostic logging, you can confirm whether or not it is in fact running before a user logs in. If it is, then manually deleting the RunOnce entry before rebooting will establish whether that entry is the cause or not, and you can move on from there. In my experience, RunOnce keys do not get executed during system startup, only once a user logs in. (You could also try putting the entry in the user's RunOnce key rather than the system one; then it won't even be loaded until the user logs in.) – Harry Johnston Mar 11 '15 at 19:57
  • Thanks for the suggestion @DavidChing but it did not make a difference. – Ian2thedv Mar 12 '15 at 07:29
  • @HarryJohnston I know it's running twice, because the installation does not launch in silent mode, so I can cancel the installation process. After I cancel it, the program is already installed, thus it must have ran before. I will try to manually delete the entry from the registry after the installation completed successfully. – Ian2thedv Mar 12 '15 at 07:29
  • You know it's running twice, but you don't know when, i.e., whether it is before or after the user logs in. That's what a log will show you. It might also be useful to know what command line is being passed; if it doesn't match the command line in the RunOnce key, then something else is making it run. – Harry Johnston Mar 12 '15 at 19:33

0 Answers0