In this article I will explain how to install a C# or VB.Net Windows Service silently without prompting for Username and Password from Command Prompt (Line) using InstallUtil.exe utility.
Installing the Windows Service silently without entering Username and Password using InstallUtil.exe
Note: I would recommend to build the command in a Notepad and save it somewhere so that you can use it multiple times.
InstallUtil /username=<Computer or Domain Name>\<Username> /password=<Password> /unattended <Path of Windows Service EXE file>
InstallUtil /username=Mudassar-PC\mudassar /password=xxxxxxx /unattended C:\Users\Mudassar\Projects\WindowsService\bin\Debug\WindowsService.exe
Now you need to open Programs => Microsoft Visual Studio 2010 => Visual Studio Tools => Visual Studio Command Prompt (2010).
Note: I am making use of Visual Studio 2010, and hence you need to use the appropriate version installed on your computer. And make sure you are logged in as Administrator. Without Administrator rights it would not allow you to install the Windows Service.
In the command prompt window, copy the InstallUtil command you have built and right click in the Command Prompt and click Paste and then press Enter key.
After successful installation you will see the following message.
You can find the Windows Service in the Services window. In order to open Services window in the Run Command type, services.msc and hit enter.