Windows启动时如何运行我的应用程序? [英] How to run my application when windows start up?

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

问题描述



我刚刚创建了一个弹出窗口.现在我想在窗口启动时自动运行它.请告诉我该怎么做?

Hi,

I just created a pop up window.Now i want to run it automatically when the windows start up.Kindly tell me how to do that?

推荐答案

将您的exe放入以下文件夹.它会在每个srartup上运行.为了进行测试,请重新启动Windows.

C:\ Documents and Settings \ Administrator \开始菜单\ Programs \ Startup
Put your exe in following folder. it will run at every srartup. For test, restart the windows.

C:\Documents and Settings\Administrator\Start Menu\Programs\Startup


为此,您需要创建Windows服务.
简单Windows服务示例 [如何在C#中开发Windows服务 [ ^ ]
For that you need to create windows service.
Simple Windows Service Sample[^]

How to develop Windows Service in C#[^]


此行将添加用于自动启动的注册表项:
This line will add a registry entry for autostart:
Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run").SetValue("keyNameForRegistry", "PATH_TO_EXECUTABLE");


并且此行将删除自动启动:


And this line will remove the autostart:

Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run").DeleteValue("keyNameForRegistry", false);


我相信这些应该有效.我现在没有时间测试它们.可能会有一些错别字.不要忘记添加,不确定是否两者都需要.


I believe these should work. I don''t have time to test them now. There might be some typos. Dont forget to add, not sure if the both are needed tho.

using Microsoft.Win32;
using System.Reflection;


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

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