C# winforms - How can I import a reg
file into the registry? The following code is displaying a confirmation box to the user (yes/no).
Process regeditProcess = Process.Start("key.reg", "/S /q"); // not working
regeditProcess.WaitForExit();
Send the file as a parameter to regedit.exe
:
Process regeditProcess = Process.Start("regedit.exe", "/s key.reg");
regeditProcess.WaitForExit();
The code in answer 2 is correct, but not complete. It will work when the directory where you are refering to has no spacings in the path/file you are refering to example C:\ProgramFiles\key.reg will work fine, but C:\Program Files\key.reg WON'T WORK because there are spaces in the path.
The solution:
string directory= @"C:\Program Files (x86)\key.reg";
Process regeditProcess = Process.Start("regedit.exe", "/s \"" + directory + "\"");
regeditProcess.WaitForExit();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With