JayNaz
JayNaz

Reputation: 363

How to delete a Registry key?

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

REG DELETE HKLM\SOFTWARE\Wow6432Node\WindowsApplication1\Status /f

Upvotes: 2

Views: 3407

Answers (3)

Bondaryuk Vladimir
Bondaryuk Vladimir

Reputation: 519

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/

Upvotes: 1

Bill
Bill

Reputation: 413

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

Upvotes: 2

ANewGuyInTown
ANewGuyInTown

Reputation: 6467

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")

Upvotes: 1

Related Questions