M
M
Max Suprunenko2015-12-17 18:56:37
C++ / C#
Max Suprunenko, 2015-12-17 18:56:37

How to register to run applications in the registry every time Windows boots through C#?

There is a piece of code. How to register to run applications in the registry every time you boot via C #? Exactly what needs to be added. I want to understand how viruses do it

static private void PicInvokeInfo()
 {
        Process proc = null;
        try
            {
                ProcessStartInfo procInfo = new ProcessStartInfo("IExplorer.exe", "http://google.com");
                proc = Process.Start(procInfo);
            }
       catch (Exception)
            {
                Console.WriteLine("Error");
            } 
  
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melz, 2015-12-17
@msuprunenko

It depends a little on the type of application. wpf? winforms? Console?

RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rkApp.SetValue("My app's name", Application.ExecutablePath.ToString());

Well, you can copy the program shortcut to
Environment.SpecialFolder.Startup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question