如何设置程序在启动时启动 [英] How do I set a program to launch at startup

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

问题描述

我有一个带有 CheckBox 选项的小应用程序,如果用户希望应用程序从 Windows 启动,可以设置该选项.

I have a small application with a CheckBox option that the user can set if they want the app to start with Windows.

我的问题是如何将应用设置为在启动时运行.

My question is how do I actually set the app to run at startup.

ps:我在 .NET 2.0 中使用 C#.

ps: I'm using C# with .NET 2.0.

推荐答案

几个选项,按优先顺序排列:

Several options, in order of preference:

  1. 将其添加到当前用户的启动文件夹中.这需要最少的权限才能运行您的应用程序,并为用户提供对正在发生的事情的最大控制和反馈.不利的一面是,确定下次他们在您的程序中查看该屏幕时是否显示已选中的复选框有点困难.
  2. 将其添加到 HKey_Current_UserSoftwareMicrosoftWindowsCurrentVersionRun 注册表项.这里唯一的问题是它需要对注册表进行写访问,而这并不总是可用.
  3. 创建一个在用户登录时触发的计划任务
  4. 将其添加到 HKey_Local_MachineSoftwareMicrosoftWindowsCurrentVersionRun 注册表项.这里唯一的问题是它需要对注册表进行写访问,而这并不总是可用.
  5. 将其设置为 Windows 服务.仅当您真的认真地并且确定要为计算机上的所有用户运行此程序时才这样做.莉>
  1. Add it to the current user's Startup folder. This requires the least permissions for your app to run, and gives the user the most control and feedback of what's going on. The down-side is it's a little more difficult determining whether to show the checkbox already checked next time they view that screen in your program.
  2. Add it to the HKey_Current_UserSoftwareMicrosoftWindowsCurrentVersionRun registry key. The only problem here is it requires write access to the registry, which isn't always available.
  3. Create a Scheduled Task that triggers on User Login
  4. Add it to the HKey_Local_MachineSoftwareMicrosoftWindowsCurrentVersionRun registry key. The only problem here is it requires write access to the registry, which isn't always available.
  5. Set it up as a windows service. Only do this if you really mean it, and you know for sure you want to run this program for all users on the computer.

这个答案现在更旧了.自从我写这篇文章以来,Windows 10 已经发布,它改变了开始菜单文件夹的工作方式......包括 Startup 文件夹.我还不清楚在该文件夹中添加或删除文件而不参考 Windows 用于这些位置的内部数据库是多么容易.

This answer is older now. Since I wrote this, Windows 10 was released, which changes how the Start Menu folders work... including the Startup folder. It's not yet clear to me how easy it is to just add or remove a file in that folder without also referencing the internal database Windows uses for these locations.

这篇关于如何设置程序在启动时启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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