How to run application as windows service

Would like the user to be able to select an option on our VB.NET windows application which then installs and starts it as a windows service. If the user run the application again it informs it is running as service and gives the option to stop the service. Any ideas how to do this ?
Who is Participating?
grayeConnect With a Mentor Commented:
Yes, that's correct...   one application would be a "pure" service with no user interface at all... and the other application would have the user interface, but no "guts"
In the "old days"... there really wasn't much difference between a ordinary application and a Windows Service.   There was even a set of tools that allowed you to convert an console app into a service.   So, to have a single application that performed both functions was an option (although a poor option).  However, that's not really practical now days.
I'd recommend that you write two applications... one that is a "pure" service and one that is a "pure" Windows Form application.   You have many choices on how to have the two pieces talk to each other.
Let us know if  you need help in writing this pair of applications
cehrnowAuthor Commented:
Would mean having two sets of code to maintain. I've seen some applications that do enable you to do this but not sure how they achieve it.
cehrnowAuthor Commented:
Oh I see what you mean..might not be practical but I'll take a look. Thanks
Tony McCreathTechnical SEO ConsultantCommented:
You could have a third library project (dll) that has the logic in it and use this common library in a simple service project and a simple application project.

Then you can share the code
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.