Search code examples
c#registry

C# - Import reg file to the registry without user confirmation box


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(); 

Solution

  • Send the file as a parameter to regedit.exe:

    Process regeditProcess = Process.Start("regedit.exe", "/s key.reg");
    regeditProcess.WaitForExit();