英文:
Why is it bad to create entries under the RunOnce key from an application that launches from the RunOnce key?
问题
Microsoft的关于Run和RunOnce注册表键的文档中有一些模糊的警告,我无法找到更详细的信息。这些警告包括:
从任何这些键运行的程序在执行过程中不应该写入该键,因为这将干扰已在该键下注册的其他程序的执行。
应用程序不应该在RunOnce下持续重新创建条目,因为这将干扰Windows安装程序。
这两种情况实际上会发生什么情况?我有一个应用程序违反了这两个建议,即它是从RunOnce键启动的,并在终止之前在RunOnce下重新创建了自己的启动命令。多年来,它一直这样做而没有问题,因此我希望在尝试替换这个应用程序之前了解实际风险是什么。我排除了应用程序崩溃后不会自动重新安排自己的明显风险。我可能为Windows创建了哪些其他问题?
英文:
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?
答案1
得分: 1
在Raymond Chen的评论和查找这个StackOverflow问题之间,我现在认为我对这两个警告有了解释:
- 从这个问题中,如果从RunOnce键运行的程序在RunOnce键中的所有条目都被处理之前重新将自身添加到RunOnce键中,就有可能进入无限循环。在我的情况下,引发我的调查的应用程序并不会在启动后立即写回RunOnce键,而是在一段时间后,显然在Windows处理RunOnce键之后,所以我们从未看到这个错误。
- 正如Raymond Chen所指出的,Windows安装程序试图在安装应用程序时不升级Windows。由于RunOnce用于运行安装程序,始终在RunOnce中有一个条目会让Windows安装程序认为有一个正在进行的安装操作,从而干扰Windows的升级。
英文:
Between Raymond Chen's comments and finding this question on StackOverflow, I think I now have an explanation for both warnings:
- 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.
- 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论