Using VB.NET with .NET Framework 2.0
I made a windows service with code to move files out of a folder on the
computer where the service is installed to a shared folder on another
computer on the local network (LAN). The problem I run into is which
security principal (service account) to use for the ServiceProcessInstaller
which is set on the properties of ServiceProcessInstaller1 under the Account
property. You can chose either LocalService, NetworkService, LocalSystem or
User.
I've ran into various problems using NetworkService and LocalSystem accounts
such as not enough permissions to delete the files from the file system or
not being able to access any network resources.
I can set the Account property of
the ServiceProccessInstaller1 to User. I've read that the account username
and password can be set for this (such as a domain user account) but I can't
find any examples of how this is done. If I was able to do this, it would
solve all my permissions problems.
Does anyone know how to do this?
Thanks,
Jim
Jim in Arizona - 13 Dec 2007 18:52 GMT
<SNIP>
> I can set the Account property of
> the ServiceProccessInstaller1 to User. I've read that the account username
[quoted text clipped - 7 lines]
> Thanks,
> Jim
I was amazed to see that no one had an answer for this. After further
investigative work along with trial and error, I found that setting the
username/password was really easy. I made a domain account, set permissions
on the folders on both ends, made a security template to give the account
permission over a specific service I wanted my code to start/stop, and
everything then worked.
When adding a Project Installer for the service, you can then view the code
of the ProjectInstaller.vb file and add the appropriate credentials there.
Imports System.ComponentModel
Imports System.Configuration.Install
Public Class ProjectInstaller
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add initialization code after the call to InitializeComponent
ServiceProcessInstaller1.Account =
ServiceProcess.ServiceAccount.User
ServiceProcessInstaller1.Username = "domainname\accountname"
ServiceProcessInstaller1.Password = "passwrd"
End Sub
End Class