2

I want to run this DOS command in C#, without executing a DOS command.

REG DELETE HKLM\SOFTWARE\Wow6432Node\WindowsApplication1\Status /f
Grant Winney
  • 65,241
  • 13
  • 115
  • 165
JayNaz
  • 343
  • 1
  • 5
  • 24

3 Answers3

1

https://msdn.microsoft.com/en-us/library/h3yfwzfx.aspx

 Registry.CurrentUser.DeleteSubKeyTree("Test9999");

best tutorial for your question

http://www.jagjot.com/2013/02/read-write-delete-windows-registry-c/

1

Or if you are looking to run the DOS command from C# then you could use

System.Diagnostics.Process.Start("cmd.exe", "REG DELETE HKLM\SOFTWARE\Wow6432Node\WindowsApplication1\Status /f")
ANewGuyInTown
  • 5,957
  • 5
  • 33
  • 45
  • This was not worked for me. Just opening command prompt as usual & passing that line of code successfully. But the key is not deleted. – JayNaz Apr 17 '15 at 05:01
1

Here's one approach. Note that you have to pass true to OpenSubKey in order to get Write permission.

var hklm = Microsoft.Win32.Registry.LocalMachine;
var subkey = hklm.OpenSubKey("Software\\Wow6432Node\\WindowsApplication1", true);
subkey.DeleteSubKey("Status");
Bill
  • 403
  • 4
  • 11