简体   繁体   中英

How to start the windows application when we starts the computer

How to start the windows application when we starts the computer. In my application I want to update the current date & time in registry.

The easiest way is to add it to the "startup" folder which you can find the Windows button -> All programs. It might be named differently if you have a localized Windows version.

Use the "Run" key in the registry.

See http://support.microsoft.com/kb/314866

You can use the Startup folder, thats easy to handle by your users if they do not want it anymore.

Then there ist the Run key in the registry, see Andrew' answer.

Also you might set up a windows service which does things not interactivly and also when no user is logged in. This service can do a single thing, start up automatic und terminate after finishing its work (it does not need to loop like most services).

You can use two easy ways to do this.

Add to Start up folder

Environment.GetFolderPath(Environment.SpecialFolder.Startup) 

Add registry entry

RegistryKey myKey= Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);    
myKey.SetValue("Your Application Name", "\"" + Application.ExecutablePath.ToString() + "\); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM