Is the process running when a user from a Windows service is not working with Access, is denied?

I am working on a project that requires an application sandbox. I can create a Windows user, create a directory, populate the directory with the application, and run the application as a user. This works fine as a console application, but when I install it as a service, I get this exception:

System.ComponentModel.Win32Exception: Access is denied at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() 

The code that throws this exception:

 _process = new Process { StartInfo = { Arguments = "", CreateNoWindow = true, ErrorDialog = false, FileName = instanceDirectory + "program.exe", WorkingDirectory = instanceDirectory, UseShellExecute = false, UserName = GetUserNameForInstance(_id), Password = GetPasswordForInstance(_id), Domain = "" }, EnableRaisingEvents = true }; _process.Exited += ProcessExited; _process.Start(); 

Again, this is only called when running as a Windows service. The service runs under the LOCAL SYSTEM in accordance with the Services panel in Windows.

Any ideas?

+4
source share
2 answers

You might be better off running the service as a domain account that has the necessary permissions for I / O (including ACL permissions).

In the example below, the Change service is configured to run as a local service account. In your case, I would suggest starting the service as DOMAIN \ UserAccount.

alt text
(source: windows-xp-services.com )

+1
source

Does the account have prerequisites for the resources you use? Is it able to read and write to the directory?

In such situations, in 99% of cases, this is a question of admission.

+1
source

All Articles