C# 开机自动启动
2021-05-03 06:27
标签:local string config class proc version tostring delete manager App.Config: C# 开机自动启动 标签:local string config class proc version tostring delete manager 原文地址:http://www.cnblogs.com/haibing0107/p/7750291.html if (ConfigurationManager.AppSettings["IsBoot"].ToString().Trim().ToUpper() == "TRUE")
{
//设置开机启动
string path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
RegistryKey rk = Registry.LocalMachine;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.SetValue("JcShutdown", path);
rk2.Close();
rk.Close();
}
else
{
string path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
RegistryKey rk = Registry.LocalMachine;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.DeleteValue("JcShutdown", false);
rk2.Close();
rk.Close();
}