I have a windows service that is designed to launch several console applications. The console applications will write to a physical log file as well as file system operations.
When the service launches the consoles, they have no access to the file system and nothing appears in the log files.
When I launch the console’s manually by double clicking on the executables, they have no issues writing to the log files.
I have tried running the service under local system, local service, network service, the local administrator account and even my own login credentials:
This is the code that launches the processes:
Process p = new Process();
p.StartInfo.FileName = agent.AgentLocation; /// Physical path to executable
p.StartInfo.CreateNoWindow = true;
p.StartInfo.ErrorDialog = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.Start();
Update:
The problem turned out that you need to set the working directory as follows: