Just as there is a startup folder for all users and the current user, there are startups in the registry as well. The startups in the registry start before the ones in the startup folders. They are located in two places. The equivalent of the user startup folder in the registry is in HKEY_CURRENT_USER. Items in that registry startup start only for that user. The equivalent of the all user startup folder is the HKEY_LOCAL_MACHINE startup, which start for all users. There are also RunOnce startups in each of those places as well. A RunOnce startup will, as it's name says, run only on the next reboot, and will be deleted as a startup after that.

HKCU startups

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

That will return a Microsoft.Win32.RegistryKey that equals the HKCU run key.

HKCU RunOnce

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\.

HKLM startups

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

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.

HKLM RunOnce

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\.

HKLM RunServices

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

SetValue

Usage: This can be used to edit an existing startupSyntax:

RegistryKeyName.SetValue(StartupName As String, StartupPath As String)

GetValue

Usage: This can be used to get a path to an existing startupSyntax:

RegistryKeyName.GetValue(StartupName As String) As Object

ValueCount (property)

Usage: Read-only property that shows how many startups are in the startup keySyntax:

RegistryKeyName.ValueCount() As Integer

GetValueNames

Usage: This can be used to get the names of all the startups in the startup keySyntax: