启动Windows时自动运行软件 [英] run my software automatically when i start windows

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

问题描述


我想要一种方法,使我可以使用c#编写的程序在每次启动Windows时自动运行.
谢谢

Hi,
I want a method that enable me to make my program which is written in c# to run automatically in every time and when i starting windows.
thanks

推荐答案

using Microsoft.Win32;

// The path to the key where Windows looks for startup applications

RegistryKey yourApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

// Add the value in the registry so that the application runs at startup

yourApp.SetValue("MyApp", Application.ExecutablePath.ToString());



如果要停止应用程序自动启动,请



And if you want to stop your application to auto start then

yourApp.DeleteValue("MyApp", false);


如果您的应用需要一直运行并且不需要用户界面,请编写它作为Windows服务.否则,只需以快捷方式的形式将您的应用程序添加到自动启动文件夹即可.
If your app needs to be running all the time and doesn''t need to have a user interface, write it as a windows service. Otherwise, just add your app to the autostart folder in the form of a shortcut.


在开始菜单的自动启动文件夹中放置指向可执行文件的链接.
Put a link to your executable in the start menu''s autostart folder.


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

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