I have read this question. I have same issue, but I don\'t understand the answer from lubos hasko. How exactly can I do it? Can you someone post me full walkthrough?
First of all, in your Service1 constructor set ServiceName property.
Excerpt from MSDN:
The minimum you need to implement in the constructor for a class inherited from ServiceBase is to set the ServiceName on your component. No other processing is specifically required in the constructor. You should handle most initialization in OnStart rather than in the constructor.
Second of all you need to pass arguments to your service when running it from command line. --install
for install, --uninstall
for uninstall - look at your switch statement it's doing it on input arguments.