How to remove from registry using C #

I have this code that puts an empty string in Autorun. I need to delete this autorun.

How can i do this?

Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnDisconnect", "AutoRun", "");
+3
source share
1 answer

You will probably need more secure coding if the key / values ​​do not exist (or the user does not have permissions to delete it), but the basics:

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows CE Services\AutoStartOnDisconnect", true);
key.DeleteValue("AutoRun", true);
+2
source

Source: https://habr.com/ru/post/1730731/


All Articles