Sign up to the jQuery Grid Subscription list.
Showing posts with label keys. Show all posts
Showing posts with label keys. Show all posts

Add registry key and delete it with vb.net

Original post by Natural_Orange at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1828643&SiteID=1

The question:

My program has an option for running at startup.
I need a way to add a registry key to:
HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Run\
And Remove it as well.

I've looked in to some other stuff but it seems way to complicated for what i need.

The accepted answer by Moayad Mardini:

To add a value to that key :

My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", YourProgramName, YourProgramPath, Microsoft.Win32.RegistryValueKind.String)

Then to delete it :

My.Computer.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue(YourProgramName)

Hope this helps