3

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

How can I do it?

Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\AutoStartOnDisconnect", "AutoRun", "");
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Gold
  • 60,526
  • 100
  • 215
  • 315
  • Although I have answered the question, this question is a duplicate of http://stackoverflow.com/questions/531151/how-to-delete-registry-value-in-c , which includes a more full answer than I have given here. – andynormancx Jan 31 '10 at 07:28

1 Answers1

2

You probably want some more defensive coding in case the key/values don't exist (or the user doesn't have permissions to delete it), but the basics are:

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows CE Services\AutoStartOnDisconnect", true);
key.DeleteValue("AutoRun", true);
andynormancx
  • 13,421
  • 6
  • 36
  • 52