C# 開機自動啟動
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(); }
App.Config:
<!--是否開機啟動 TRUE 啟動 FALSE 禁止-->
<add key="IsBoot" value="FALSE"/>

浙公網安備 33010602011771號