.NET framework provided “installutil. In the folder where the executable for your service application resides, run this utility to install or uninstall the application. Following is the syntax for install and uninstall.
installutil myService.exe
installutil /u myService
Using command line to install Windows Service
This usefull command is not the most intuitive command. The sc command allows you to install/delete Windows Services. I have used this nifty command quite often in the past project to remove erroneous Windows Service. Microsoft has a good KB article.
Things to watch out is the escaping of the binPath. If there are spaces in your binPath you must escape it using the " character which must be escaped again using the \ character.
For example: c:\sc create MyService binPath= "\"c:\program files\my service\service.exe\""