如何从基于 IIS 的 Web 服务启动控制台应用程序,并使其在处理时可见?

发布于 2024-10-02 12:43:01 字数 483 浏览 0 评论 0原文

我正在尝试从基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

大姐,你呐 2024-10-09 12:43:01

我认为 .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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文