Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Installing a Service throws ServiceProcessInstaller.Account exception

Status
Not open for further replies.

K1BBQ

Programmer
May 28, 2001
27
0
0
US
I've written a Service application that needs to get file access to a remote computer on a simple local network, just a workgroup. I found that the File.Copy and File.Delete that I'm accustomed to in Windows Forms applications won't work, unless I set the Service to Logon as a User with network privleges -- the System account that is the default when the Service is Installed won't do that.

What I can't figure out is how to set the Service to do that for itself in the code. I know that you can set StartType in code, but I'm having problems with the ServiceProcessInstaller.Account property. The documentation looks really straightforward -- just set

ServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.User

and the Username and Password properties, and it looks like it should do exactly what I do now manually.

But when I install the Service I get an Exception - the account name is invalid or does not exist. All my existing user accounts fail the same way.

Is there something I'm missing? Is there something I need to set somewhere else, a Security Policy thing?
 
If I set it to

ServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.NetworkService

the Service starts and then stops, with a message saying it has no work to do (?????)

If I set it to

ServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalService

I get an exception saying that access to the remote system is denied.
 
Here's the answer at last! I have to enter the username as

"<machinename>\username"

not just the username by itself.

Such a simple detail!!!

I found the answer on another board where someone had exactly the same problem.
 
Perhaps you could help me out on a similar problem. I'm trying to install a windows service on another machine on the network.

If I set the following properties for the serviceprocessinstaller, should the service then appear in the services on the remote machine?

Me.ServiceProcessInstaller1.Account = system.ServiceProcess.ServiceAccount.NetworkService
Me.ServiceProcessInstaller1.Password = "myPassord"
Me.ServiceProcessInstaller1.Username = "<Macine1>\user
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top