在Windows 8启动期间自动运行C#应用程序的方法 [英] Ways to autorun my C# app during startup in Windows 8
问题描述
我目前在Windows 8启动期间无法自动运行我的应用程序。我试图将应用程序放入注册表中。实际上,我已经尝试了本地计算机方法和当前用户方法:
I currently have problem in making my app autorun during startup in windows 8. I have tried to put the app in the registry. In fact I have tried both Local Machine and Current User approach:
RegistryKey rkHKLM = Registry.LocalMachine;
RegistryKey rkRun;
RegistryKey rkHKCU = Registry.CurrentUser;
RegistryKey rkRun1;
rkRun = rkHKLM.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkRun1 = rkHKCU.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (checkBox1.Checked)
{
rkRun.SetValue("MyApp", Application.ExecutablePath);
rkRun1.SetValue("MyApp", Application.ExecutablePath);
}
else
{
rkRun.DeleteValue("MyApp");
rkRun1.DeleteValue("MyApp");
}
此方法在Windows 8中不起作用。但是我没有此方法Windows 7或XP中出现问题。
Windows 8有什么不同吗?有什么新方法吗?
This method does not work in Windows 8. But I don't have this problem in windows 7 or XP. Anything different for Windows 8? Is it there is any new approach?
- 为您提供的信息,我已将应用设置为以管理员身份运行,但仍无法自动运行
推荐答案
将快捷方式放入:
c:\ \用户\ {登录名} \AppData\漫游\Microsoft\Windows\开始菜单\程序\启动应在您登录时运行该应用程序。
Putting a shortcut in: c:\Users\{login name}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup should run the application when you log in.
(可选)您可以创建任务。您可以在触发器中选择是在登录时还是在计算机启动时运行。
Optionally, you could create task. You can in the trigger choose whether it should run on log-in or when the computer starts.
任务计划程序托管包装器是一个有用的库,可用于以编程方式创建任务。
The "Task Scheduler Managed Wrapper" is a helpful library for creating tasks programmatically.
这篇关于在Windows 8启动期间自动运行C#应用程序的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!