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.
In my previous article I have already explained How to install and uninstall Windows Service using InstallUtil.exe from Command Prompt (Line). This article is an extension of the previous article as it covers the part of installing Windows Service using InstallUtil.exe utility without entering Username and Password in the InstallUtil syntax.
 
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 Syntax
InstallUtil /username=<Computer or Domain Name>\<Username> /password=<Password> /unattended <Path of Windows Service EXE file>
 
Example:
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.
Install Windows Service silently without entering Username and Password using InstallItil.exe from Command Prompt (Line)
After successful installation you will see the following message.
Install Windows Service silently without entering Username and Password using InstallItil.exe from Command Prompt (Line)
 
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.
Install Windows Service silently without entering Username and Password using InstallItil.exe from Command Prompt (Line)