A self-hosting self-installing windows service
This project demonstrates a service that can run as a console mode daeman or as a windows service, and can install and uninstall itself.
See my code project article: https://www.codeproject.com/Articles/5256600/SelfServe-A-Self-hosting-Self-installing-Windows-Service