It runs twice because you're setting the registry key in both
RunOnce. If you want it to run each time,
just set it in the
Run key. The
RunOnce key is
just for programs that you want to (as the name implies) run only once. The
registry entry is automatically removed from
RunOnce after the
If you want to delay the program until the shell has started up, the
easiest way (although a bit hacky) is to just put a
Thread.Sleep(60000) at the very start of the the program.
If you want a more sophisticated solution, have a look here: C#
- How to know when Windows is "settled" after startup?