首页 > 代码库 > C# 设置程序开机自启动

C# 设置程序开机自启动

设置启动

//设置开机自启动  
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMachine;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.SetValue("JcShutdown", path);
rk2.Close();
rk.Close();

 

取消启动

//"取消开机自启动
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMachine;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.DeleteValue("JcShutdown", false);
rk2.Close();
rk.Close();
    

C# 设置程序开机自启动