Process.Start will not work when invoked from Task Scheduler on server

896 views Asked by At

Good Day

I am having issues using Process.Start() when I deploy to a server.
As usual "It works fine on my machine", which does not help. On the server though, when using task manager to kick off the program, I can see in the log the process.start method is called.
But the external program never launches.
If I run the external program with the same working directory, program, and args on the command line everything works as expected.

Here is my code if anyone can help.

<add key="StartProgram" value="C:\Program Files (x86)\WinTask\bin\TaskExec.exe"/>
<add key="StartUpDirectory" value="D:\DS3\WeatherDownLoad\RunDownload"/>
<add key="Args" value="ProdDownLoadWeather.rob"/>


Process process = new Process();
process.StartInfo.FileName = settings["StartProgram"];
process.StartInfo.Arguments = settings["Args"];
process.StartInfo.WorkingDirectory = settings["StartUpDirectory"];
process.StartInfo.CreateNoWindow = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;

process.Start();
process.WaitForExit();
1

There are 1 answers

0
Bob Cummings On

Turns out I was not doing anything incorrect. A third party component requires it's own desktop. So when I was using Remote Desktop it could not open another desktop. Thanks for trying to help.