The HKCU startups are located in a registry key under the HKCU base key. The exact path of that key is HKCU\Software\Microsoft\Windows\CurrentVersion\Run\. To access that registry key in your code, use
My.Computer.Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft") _ .OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Run")
That will return a Microsoft.Win32.RegistryKey that equals the HKCU run key.
The HKCU run once's are located in almost the same place as the normal startups, the only only difference is they are located in a key called RunOnce instead of Run. The full path of the HKCU runonce is HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\.
The HKLM startups are located in the same path at the HKCU startups, except they are under the base key HKLM. The full path of the HKLM startups is HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\. To access that key in your code, use
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft") _ .OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Run")
The HKLM starups can be accessed and edited in the same way as the HKCU startups, the only difference between them is that they one is all user and one is current user. We will talk about how to edit registry keys later.
The HKLM run once's can be access in the same way as the HKCU run once's. The full path of the HKLM run once's is HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\.
This is something we have not talked about yet. Unlike the HKCU key, the HKLM key has a RunServices key. The path of the RunServices key is HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices\. Don't confuse services with standard startups, because they are different, and for someone who is just learning about registry startups, you probably shouldn't mess with Services until you know a bit more about them. Learn more about services here.
Editing the Microsoft.Win32.RegistryKey class
There are many methods in the registrykey class. Here, we will only talk about the ones that could possibly be of use when the registrykey is a startup key. These methods are
Usage: This can be used to edit an existing startup
RegistryKeyName.SetValue(StartupName As String, StartupPath As String)
Usage: This can be used to get a path to an existing startup
RegistryKeyName.GetValue(StartupName As String) As Object
Usage: Read-only property that shows how many startups are in the startup key
RegistryKeyName.ValueCount() As Integer
Usage: This can be used to get the names of all the startups in the startup key
RegistryKeyName.GetValueNames() As String()
Usage: This can be used to delete an existing startup
RegistryKeyName.DeleteValue(StartupName As String)