65

I have developed a windows service using C# and Visual Studio 2008. I have Windows XP SP2 installed on my machine. When I try to install the service using the installutil tool, after entering the username and password, I get the following error.

An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The account name is invalid or does not exist, or the password is invalid for the account name specified.

But the user does exist. I had created the user through control panel → User accountsCreate new account.

The command I used for installing the service was:

installutil /i TestService.exe

How can I resolve the issue?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sambha
  • 653
  • 1
  • 5
  • 4

3 Answers3

146

If the account is a local user account, try to use .\username when installutil prompts for the username and password.

The .\ stands for local machine.

Services require a fully qualified username (with domain), so when installing you need to be explicit about local user accounts.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • 1
    Just to clarify, this means if it's a domain user then usage is `domainName\username`. – Beytan Kurt Dec 18 '18 at 12:25
  • I had this same error, too, and it ended up having nothing to do with the account or local login policy. Make sure you have the correct framework version installed! Our service was created against .NET 4.8 and that runtime was not on the machine (only had 4.5). – Kris Oye Apr 21 '22 at 18:37
3

The account may also need to be given the "Log on as a service" account right; pass the SE_SERVICE_LOGON_NAME constant to the LsaAddAccountRights() API.

devstuff
  • 8,277
  • 1
  • 27
  • 33
-1

I solved this by changing ServiceProcessInstaller.Account to LocalSystem, and it works for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Deepp
  • 93
  • 1
  • 7
  • 3
    this is not an answer... It seems like a comment – The Hungry Dictator Jan 16 '14 at 08:19
  • 1
    changing the account amy not be the best solution, but it is an answer not just a "comment" – Brian Jan 28 '14 at 17:33
  • 1
    This is not a recommended approach. Local System has extensive privileges on the computer; it is similar to an Adminstrator. See [this answer](http://stackoverflow.com/questions/510170/the-difference-between-the-local-system-account-and-the-network-service-acco) for an overview of built-in accounts. – Jason Capriotti Jan 14 '16 at 22:14