I plan to write a windows service to initiate all the business processing, and a Windows Forms app to do all its configuration.
Can the windows user under which the service runs be edited in code as part of the configuration?
I plan to write a windows service to initiate all the business processing, and a Windows Forms app to do all its configuration.
Can the windows user under which the service runs be edited in code as part of the configuration?
It can be altered programatically when the service is installed. Have a look at the System.ServiceProcess.ServiceProcessInstaller class. It has properties to set the the account, username and password. You need to make an instance of this class with the correct settings and add it to the Installers collection of your custom (System.Configuration.Install.Installer) installer.
The account is usually set by the service installer. This is done via the ServiceProcessInstaller component
The properties are:
You should be able to set them using the VS designer
If you want to change an existing service's startup account using a separate WinForms application, you have to fiddle with the registry I think (but I don't know what registry keys to change)
You will need to use the ServiceInstaller class in conjuction with the ServiceProcessInstaller class. To set the account to run the service under, you need to set the Account property.