Programmatically start application on login

前端 未结 2 1791
长情又很酷
长情又很酷 2021-01-03 05:46

What\'s the best way to programmatically start an application on login for Windows? I know you can do it by adding an item to the startup folder in the start menu, but I wan

相关标签:
2条回答
  • 2021-01-03 06:09

    This is how you could do it in C#:

    Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
              "MyStartUp",
              @"C:\StartUpApp.exe");
    

    You basically need to add a registry entry. The above one works on start-up. There are a few more. I recommend that you download a tool like Autoruns to see all possible locations.

    0 讨论(0)
  • 2021-01-03 06:21

    How about installing your program as a Windows service? Services can be switched between 'disabled', 'manual' and 'automatic', and you can access services from within your code (even from a Java application) and manipulate its state.

    Just a thought.

    Yuval =8-)

    0 讨论(0)
提交回复
热议问题