实现效果:
知识运用:
Registry类的SetValue方法 //设置注册表项中的名称/值对的值
public static void SetValue (string keyName,string value Name ,Object value)
实现代码:
private void button1_Click(object sender, EventArgs e) { Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "RestrictRun", 1); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun", "1", "cmd.exe"); MessageBox.Show("设置成功!本次设置的为仅允许运行 CMD\n注销后生效"); }