Delete Regedit Windows Key

1

I'm doing a program in C # to automate a situation here in the company, but I'm experiencing problems with it

I want to delete a windows registry key located in HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ MSLicensing

In case I would like to delete the MSLicensing key or delete everything inside it.

I'm using the following command

string caminho = @"SOFTWARE\Microsoft\MSLicensing";
Registry.LocalMachine.DeleteSubKey(caminho, true);

I am running VS as an administrator and I have already put a high level manifest and still have nothing to delete.

Thanks for everyone's attention.

    
asked by anonymous 05.11.2018 / 20:49

1 answer

0

First, add this reference:

using Microsoft.Win32;

And to delete use this excerpt:

string keyName = @"SOFTWARE\Microsoft\MSLicensing";
RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true);
key.DeleteValue("ValorASerDeletado");
    
06.11.2018 / 11:49