54

I am being prompted for user name and password while installing my windows service created in c#. I used the installutil tool to install my service. What is the reason for asking the user name password credentials?

one noa
  • 345
  • 1
  • 3
  • 10
Partha
  • 2,062
  • 6
  • 24
  • 31
  • 1
    This stackoverflow question might be what you want: http://stackoverflow.com/questions/140054/using-installutil-and-silently-setting-a-windows-service-logon-username-password – Alex Bagnolini Dec 22 '09 at 10:47

5 Answers5

121

If you do not want your windows service to prompt for Username/Password, go to Installer Class(Design Mode) of the service, then right click on ServiceProcessInstaller -> Properties; set Account as Local Service.

Now use the installutil command. It will not ask for Username/Password.

Matthew Lock
  • 13,144
  • 12
  • 92
  • 130
Satyendra Kumar
  • 1,211
  • 1
  • 8
  • 3
  • 9
    For more clarification, in Visual Studio 2010 you will right click on the "ProjectInstaller.cs" and then click "Designer". Then follow the rest of Satyendra's steps. – Flea Apr 17 '13 at 19:27
  • Just make sure you have the permissions you need if you do this. – Steve Sep 18 '18 at 21:02
  • I also had to right click on the service in Services (Local) and set Log on as: "Local System account" in the Log On tab. – Matthew Lock Apr 23 '19 at 08:24
7

Right click ServiceProcessInstaller file - > go to properties - > Choose account as LocalService.

enter image description here

gbeaven
  • 1,522
  • 2
  • 20
  • 40
4

Every process or service in windows runs under a particular windows user account.

The user account is used as identity for any action performed by the service or the process. If your process or service requires to do any task which requires security privileges, it will be granted only on basis of the user-identity associated with the process/service.

Say you're running you service under a user named "SVCUSER" and the service requires to do disk I/O in any location of the disk. If the user "SVCUSER" does not have rights or authorization to perform disk I/O for the given location, the service will not be able perform the operation and throw related security-exception.

this. __curious_geek
  • 42,787
  • 22
  • 113
  • 137
3

Your windows service needs a user name and password for the same reason that you are asked for your username and password on login. To identify you and to set your access levels and permissions on windows.

This is not a problem, it is supposed to work this way.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
0

Add this line in ProjectInstaller.Designer.cs file.

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
Shyam Vemula
  • 591
  • 2
  • 14