操作注册表案例,开机启动CMD
static void Main(string[] args) { //打开注册表子项 RegistryKey key = Registry.LocalMachine .OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); //增加开机启动项 key.SetValue("Cmd", "C:\\Windows\\System32\\cmd.exe"); }
static void Main(string[] args) { //打开注册表子项 RegistryKey key = Registry.LocalMachine .OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); //增加开机启动项 key.SetValue("Cmd", "C:\\Windows\\System32\\cmd.exe"); }