如何在重启后自动运行应用程序?
如何在重启后自动运行应用程序? (通过 C# 代码)我使用应用程序的路径在注册表中的“runOnce”键中创建一个新字符串。 操作系统在加载操作系统之前运行此应用程序 我的问题是:我的应用程序加载但资源管理器不加载,在我关闭应用程序后,资源管理器加载 我在APP中重新启动计算机,重新启动后我希望我的APP重新打开
how can I run an app automatic after restart?
(by c# code) I create A new string in 'runOnce' key in registry with the path of the App.
the OS run this APP before it load the OS
my problem is: My APP loads but explorer doesn't load, after I close my APP, explorer loads
I restart the computer in APP, and after restart I want that my APP reopen
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您从应用程序中单击重新启动时,请对注册表进行以下修改:
在
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
注册表分支中创建一个条目。用于
创建条目。
并
设置运行路径。
系统重新启动后,您的应用程序启动并通过调用以下命令删除重新启动条目:
When you click restart from your app, make the following modifications to the registry:
Create an entry in
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
registry branch.Use
to create an entry.
And
to set the run path.
After the system has restarted, your app starts and removes the restart entry by calling this:
看来您最好的选择是将程序添加到 RunOnce,而不是 Run。这样,它将在下次重新启动后启动,但您不必担心之后会删除密钥。
It seems like your best bet would be to add your program to RunOnce, instead of Run. That way it will be started after the next reboot, but you won't have to worry about erasing the key afterwards.
这是一个更好的答案,因为您不应该创建子密钥。这也会自动处理。
This is a better answer as you should not create a SubKey. Also this will automatically dispose.