質問

Let's assume that I have a C# .NET 2.0+ application running on windows. And at some certain point in time it forces Windows to restart. How can I automatically start this application again after windows restarts to continue program to do some work?? I need to do it in code somehow, but I don't know how. Point me, please to some info on this or some pieces of code will be great. Thanks!

役に立ちましたか?

解決

There are several options.

1 Register it as a windows service.

2 Put a link in startup section of Start Button

3 Create an entry in registry (HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run)

The best one is the first one, as this is the recommended method to automatically start applications. You will benefit from:

  • Standard control in services.msc
  • Applications that allow you to monitor windows services status
  • Msbuild or powershell commands that allow you to easily interact with your service in order to deploy as part of your continuous integration process.

But your application will require some changes and has to be a console app.. Check this link to make yourself an idea. If you have a winforms app go for options 2 or 3 (3 is better)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top