如何在重启后自动运行应用程序?

sar*_*i k 8 c# regedit

如何在重启后自动运行应用程序?(通过c#代码)我在注册表中的'runOnce'键中创建一个新的字符串,其中包含App的路径.操作系统在加载操作系统之前运行此操作系统我的问题是:我的APP加载但资源管理器没有加载,关闭我的APP后,资源管理器加载我在APP中重新启动计算机,重启后我希望我的APP重新打开

Max*_*lov 9

当您从应用程序中单击"重新启动"时,请对注册表进行以下修改:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run注册表分支中创建一个条目.

使用

Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\YourAppName");
Run Code Online (Sandbox Code Playgroud)

创建一个条目.

RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\YourAppName", true);

myKey.SetValue("YourAppName", "AppExecutablePath", RegistryValueKind.String);
Run Code Online (Sandbox Code Playgroud)

设置运行路径.

系统重新启动后,您的应用程序将启动并通过调用以下命令删除重新启动条目:

Registry.LocalMachine.DeleteSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\YourAppName");
Run Code Online (Sandbox Code Playgroud)