Here is How To Install Windows Service via Command-Line with the simple instructions provided on this page. You will need the .net framework which will provide a command-line installer utility for installing services on the Windows system. You can use installutil.exe to install Windows service via the command line. You can get the .net 4 framework under C:\Windows\Microsoft.NET\Framework\v4.0.30319 directory.
How To Install Windows Service Via Command Line?
First of all, go to the directory where the .net framework is located and then run installutil.exe
cd "C:\Windows\Microsoft.NET\Framework\v4.0.30319\" c:\> installutil.exe "C:\Users\Rahul\WindowsService\bin\Debug\WindowsService.exe"
If the system asks for further authentication then input the username and password. Remember the
username Admin should start with “.\” as shown in the screen below.
To Uninstall Windows Service
To Uninstall the Windows service use the “-u” option with the same command as installation. The command for uninstallation should look like below:
c:\> cd "C:\Windows\Microsoft.NET\Framework\v4.0.30319\" c:\> installutil.exe -u "C:\Users\Rahul\WindowsService\bin\Debug\WindowsService.exe"