I\'m looking for different ways with strengths/weaknesses for converting a console application we are using long term in to a windows service. We use something called java serv
I would be tempted to create an empty windows service project, and just grab the bits that deal with a service; it isn't a lot - a few references and some of the code in Main
. You can actually have your existing console work both as a service and as a console - either by checking the args to Main
and using (for example) a "-console" switch, or I believe you can check Environment.UserInteractive
.
If it is in "console" mode, run your code as you do now; if it is in service mode, run the code you grabbed from the template project.
For info, you can also have the same exe work as the installer/uninstaller for the service! I do this with "-install" / "-uninstall" switches. For an example, see here.