1、Startup启动文件夹(windows 9x/XP/2000)
C:\Documents and Settings\All Users\「开始」菜单\程序\启动
2、注册表中RUN项添加自启动
[HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnce]
[HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run]
[HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnceEx]
[HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunEX]
[HKEY_LOCAL_USER/Software/Microsoft/Windows/CurrentVersion/RunOnce]
[HKEY_LOCAL_USER/Software/Microsoft/Windows/CurrentVersion/Run]
[HKEY_LOCAL_USER/Software/Microsoft/Windows/CurrentVersion/RunOnceEX]
[HKEY_LOCAL_USER/Software/Microsoft/Windows/CurrentVersion/RunEX]
3、服务:计算机管理->服务列表->设为自动的服务会随系统启动
4、文件关联:例如exe文件,注册表项为"HKEY_CLASSES_ROOT/exefile/shell/open/command"%1"%\'
5、随系统启动的系统配置文件WIN.INI中的"RUN="和"LOAD="
6、随系统启动的系统配置文件SYSTEM.INI中的boot项中的"shell=explorer.exeC:\windows\filename"
7、计划任务,存放的定时作业可设置系统启动时任意时间调用程序。
01 #region 开机自动启动
02 /// <summary>
03 ///开机自动启动
04 /// </summary>
05 /// <param name="keyName">注册表key.</param>
06 /// <param name="filePath">软件路径</param>
07 /// <returns>返回:Boolean 类型</returns>
08 /// 楼雨:2010-11-22 15:18
09 public static bool SetAutoRun(string keyName, string filePath)
10 {
11 try
12 {
13 RegistryKey hkml = Registry.LocalMachine;
14 RegistryKey runKey = hkml.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
15 runKey.SetValue(keyName, filePath);
16 runKey.Close();
17 }
18 catch
19 {
20 return false;
21 }
22 return true;
23 }
24 /// <summary>
25 /// 判断是否已经设置为开机启动
26 /// </summary>
27 /// <param name="keyName">注册表key</param>
28 /// 楼雨:2010-12-1 16:43
29 public bool IsAutoRun(string keyName)
30 {
31 try
32 {
33 bool _exit = false;
34 RegistryKey hkml = Registry.LocalMachine;
35 RegistryKey runKey = hkml.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
36
37 string[] subkeyNames;
38 subkeyNames = runKey.GetValueNames();
39 foreach (string kName in subkeyNames)
40 {
41 if (kName == keyName)
42 {
43 _exit = true;
44 return _exit;
45 }
46 }
47 return _exit;
48 }
49 catch
50 {
51 return false;
52 }
53 }
54 #endregion
01 #region 开机自动启动
02 /// <summary>
03 ///开机自动启动
04 /// </summary>
05 /// <param name="keyName">注册表key.</param>
06 /// <param name="filePath">软件路径</param>
07 /// <returns>返回:Boolean 类型</returns>
08 /// 楼雨:2010-11-22 15:18
09 public static bool SetAutoRun(string keyName, string filePath)
10 {
11 try
12 {
13 RegistryKey hkml = Registry.LocalMachine;
14 RegistryKey runKey = hkml.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
15 runKey.SetValue(keyName, filePath);
16 runKey.Close();
17 }
18 catch
19 {
20 return false;
21 }
22 return true;
23 }
24 /// <summary>
25 /// 判断是否已经设置为开机启动
26 /// </summary>
27 /// <param name="keyName">注册表key</param>
28 /// 楼雨:2010-12-1 16:43
29 public bool IsAutoRun(string keyName)
30 {
31 try
32 {
33 bool _exit = false;
34 RegistryKey hkml = Registry.LocalMachine;
35 RegistryKey runKey = hkml.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
36
37 string[] subkeyNames;
38 subkeyNames = runKey.GetValueNames();
39 foreach (string kName in subkeyNames)
40 {
41 if (kName == keyName)
42 {
43 _exit = true;
44 return _exit;
45 }
46 }
47 return _exit;
48 }
49 catch
50 {
51 return false;
52 }
53 }
54 #endregion