如何从基于 IIS 的 Web 服务启动控制台应用程序,并使其在处理时可见?
我正在尝试从基于 IIS 的 Web 服务启动控制台应用程序,但它在服务器上不可见。
到目前为止的代码是:
string downloaderPath = ConfigurationManager.AppSettings["DownloaderExePath"];
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
si.FileName = downloaderPath;
si.UseShellExecute = true; //false doesn't make a difference
System.Diagnostics.Process.Start(si);
进程触发,但有错误。想让它在屏幕上可见,这可能吗?
I'm trying to launch a console app from an IIS based web service, but its not visible on the server.
Code so far is:
string downloaderPath = ConfigurationManager.AppSettings["DownloaderExePath"];
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
si.FileName = downloaderPath;
si.UseShellExecute = true; //false doesn't make a difference
System.Diagnostics.Process.Start(si);
The process fires, but with errors. Would like to have it visible on the screen, is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 .Net BCL 中没有任何内容可以让您这样做,即使这是可能的。
您需要在当前的“交互式”用户会话中启动应用程序。从 Web 服务启动应用程序时,它在 IIS 会话中运行(作为服务)。
也许查看像 psexec 这样的工具可能会帮助你了解如何实现这一点在职的。
或者,将错误记录到文件中和/或尝试将调试器连接到 iis
进程(w3wp.exe)
I don't think there is anything in the .Net BCL that would allow you to do so, even if it is at all possible.
You would need to start the application in the current 'interactive' user session. When starting the app from the webservice, it is running in the session of IIS (as a service).
Perhaps looking at tools like psexec might shed some light on how to get this working.
Alternatively, log the errors to a file and/or attempt to hook up a debugger to the iis
process (w3wp.exe)