How to open your program at startup?

I want my users to be able to open my program at startup. I am coding in vb.net. How can i do this?

I can not find the "System startup" folder anywhere where I could just copy the shortcut.

Thanks for the help!

+3
source share
4 answers

Use the registry to record the name (key) and full path (value) of your program.

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

Note. This will load when the user logs in, not when the system starts. You need a service, as Joel said, to do this.

In C # .net do the following:

public string GetRegistryValue(String key)
{
   return Convert.ToString(Registry.GetValue (@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", key, ""));
}

public void SetRegistryValue(String key, String value)
{
   Registry.SetValue (@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", key, value);
}

VB.net code is very similar.

+3
source

, , . , , , . , , .

+2

, . Windows XP Vista "" .

C:\Documents and Settings\<username>\Start Menu\Programs\Startup

I believe this is the recommended place to register applications to run. Most installation packages offer the ability to register an application to automatically launch when creating and running .msi or another installer.

+1
source

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


All Articles