在登录时以编程方式启动应用程序 [英] Programmatically start application on login

查看:29
本文介绍了在登录时以编程方式启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在登录 Windows 时以编程方式启动应用程序的最佳方法是什么?我知道您可以通过在开始菜单中的启动文件夹中添加一个项目来实现,但我希望在我的应用程序中有一个选项来关闭和打开它.

What's the best way to programmatically start an application on login for Windows? I know you can do it by adding an item to the startup folder in the start menu, but I want to have an option in my application to turn it off and on.

推荐答案

这就是你在 C# 中可以做到的:

This is how you could do it in C#:

Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
          "MyStartUp",
          @"C:\StartUpApp.exe");

您基本上需要添加一个注册表项.上面的一个在启动时起作用.还有几个.我建议您下载类似 Autoruns 之类的工具,以查看所有可能的位置.

You basically need to add a registry entry. The above one works on start-up. There are a few more. I recommend that you download a tool like Autoruns to see all possible locations.

这篇关于在登录时以编程方式启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆