简体   繁体   中英

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

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();

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM