我有个问题。我执行如下代码。之后,我查看了regedit文件,未添加“ test.reg”文件。您如何看待这个问题
regedit文件的内容为:
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Wow6432Node\efe]
"key1"="value"
"key2"="value2"
代码是:
static void Main()
{
Process regeditProcess = Process.Start("regedit.exe", "/s " + @"D:\Projects\efe\efe\bin\Debug\test.reg");
regeditProcess.WaitForExit();
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
谢谢你的建议...
最佳答案
如果您具有管理权限,那么这应该可以正常工作,您可以尝试直接从c#创建注册表项:
Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"Software\Wow6432Node\efe");
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Wow6432Node\efe",true).SetValue("key1", "value", Microsoft.Win32.RegistryValueKind.String);
我从头输入了代码,因此也许您需要进行一些更改。为此,您还需要对应用程序具有管理权限。