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?
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?