InstallUtil requires computer name to be specified in front of user account when installing services

Posted: (EET/GMT+2)

 

If you use C# to develop a Windows Service application (a "service"), you will probably use the InstallUtil utility for initial installations on test machines. If you are like me, you do such tests inside virtual machines.

Now, I have a set of virtual machines ready-made, and most of them don't belong (are member of) any domain; instead they just belong to the default workgroup. In such a situation, InstallUtil will require you to prefix your user account name under which the service is going to run with your computer name. If you do not, you will see the following error message:

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.

The Rollback phase of the installation is beginning.

Depending on your installer classes/code, you might wish to prompt the user for the credentials under which your new service will run. If you simply type in a name of a local account, say, "Administrator", you will get the above error message. To remedy this situation, use a either one of these constructs:

COMPUTERNAME\Administrator

.\Administrator

This will fix the problem. InstallUtils is developed with Active Directory and domain accounts in mind, and thus expects the DOMAIN\ACCOUNT construct. But you can substitute the dot "." instead of the domain if your test machine isn't part of a domain.