Console application not starting processes when scheduled in Windows

て烟熏妆下的殇ゞ 提交于 2019-12-13 03:48:01

问题


I have a simple .NET console app in C#, that runs an external process "pscp" (putty secure copy). This works great when I just run the .exe.

However, when I schedule the application in windows scheduled tasks, the application does not seem to open the external process pscp.exe. Normally it should pop up an extra console screen and open pscp.exe there. This works, just not when scheduled.

I start the process like this:

pscp.FileName = "pscp.exe";
Process p = Process.Start(pscp);
p.WaitForExit();

Any ideas on how to fix this?


回答1:


Starting cmd with the /c argument runs "your exe" in a new cmd window.




回答2:


The scheduled task runs under a different identity. Make sure that's working. Also, make sure you wrap the call to your exe with a cmd /c "your exe".



来源:https://stackoverflow.com/questions/5787015/console-application-not-starting-processes-when-scheduled-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!