ho开发者_运维技巧w to make application startup without using startup folder , is there any way instead of Windows Service ?
Registry entry could do this.
The Registry keys most often involved with startup have the word "Run" in them somewhere. They are listed below using the abbreviation HKLM for the major key (or "hive") called "HKEY_LOCAL_MACHINE" and HKCU for for the hive "HKEY_CURRENT_USER"
HKLM\Software\Microsoft\Windows\CurrentVersion\Run HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce HKCU\Software\Microsoft\Windows\CurrentVersion\Run HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
You probably have several items in some of them already. Just add additional items there.
Here is how HKLM\Software\Microsoft\Windows\CurrentVersion\Run might look in Regedit (Run-> type "regedit" -> Enter). The right pane shows a number of programs that will run when this system is started.
Hope this helps :-)
You can create key in the registry:
RegistryKey app = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
app.SetValue("name", Application.ExecutablePath.ToString());
This will add it to startup apps for current user.
put it to registry like "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
If you wanna set your application start just for specific user, use this:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
and if u want to run in all users use thisone:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
精彩评论