0

Microsoft's documentation on the Run and RunOnce keys has some vague warnings that I can't actually find more detailed information about. These warnings are:

A program that is run from any of these keys should not write to the key during its execution because this will interfere with the execution of other programs registered under the key.

An application must not continually recreate entries under RunOnce because this will interfere with Windows Setup.

What actually happens in these two scenarios? I have an app that goes against both of these recommendations, i.e. it is launched from the RunOnce key and recreates it's own launch command under RunOnce before terminating. It has done so for years without problems, so I'd like to understand what the actual risk is before I dive in and try to replace this app. I am discounting the obvious risk that if the app crashes it won't necessarily reschedule itself. What other problems could I be creating for Windows?

chippies
  • 1,595
  • 10
  • 20
  • Windows Setup assumes that an active Runonce entry means that an application installation is incomplete. (Since that is the intended purpose of Runonce: to complete an install after a reboot.) – Raymond Chen Jul 10 '23 at 18:43
  • When an application complains that one must restart one's computer because of not restarting following a previous installation, is it actually checking the RunOnce keys? – chippies Jul 10 '23 at 19:21
  • You naturally need to ask the author of each application why that application displays any particular message. – Raymond Chen Jul 10 '23 at 19:25
  • I read a bit on Windows Setup. The app that this question is related to runs long after Windows is installed. From what I read about Windows Setup, that is only involved in installing Windows from scratch. Searching for "windows setup" and "runonce" turned up links about customising the Windows installation process. I'm not doing that. My own ignorance here - I don't understand what Windows Setup is doing with RunOnce entries after Windows is installed. I appreciate the pointers to help me understand. – chippies Jul 10 '23 at 19:47
  • 1
    Windows Setup is also used to upgrade from one version of Windows to another. A perpetual RunOnce entry will impair upgrades because the system tries not to upgrade while an application is still installing. (That creates the weird situation where an application starts installing on one version of Windows and finishes installing on a different version of Windows, which most applications don't handle well.) – Raymond Chen Jul 10 '23 at 23:41
  • Thank you @RaymondChen, that explains the second warning. Regarding the first warning, how does it interfere with other programs under the RunOnce key? – chippies Jul 11 '23 at 08:00

1 Answers1

1

Between Raymond Chen's comments and finding this question on StackOverflow, I think I now have an explanation for both warnings:

  1. From this question, it is possible to enter an infinite loop if a program run from a RunOnce key re-adds itself to the RunOnce key before all entries in the RunOnce key have been processed. In my case, the app that sparked my investigation doesn't write back to the RunOnce key immediately after starting, but rather a while later and obviously after Windows has processed the RunOnce key, so we never saw this bug.
  2. As Raymond Chen pointed out, Windows Setup tries not to upgrade Windows while an application is being installed. Since RunOnce is meant for running installers, always having an entry in RunOnce will fool Windows Setup into thinking there is an installation in progress, interfering with Windows upgrades.
chippies
  • 1,595
  • 10
  • 20