简体   繁体   English

在Windows Service中重定向stdout和stderr

[英]Redirect stdout and stderr in Windows Service

I created a windows service that can execute processes exposed via wcf (internal use only). 我创建了一个Windows服务,该服务可以执行通过wcf公开的进程(仅供内部使用)。 I recently ran into an issue where this works fine if I execute the process (cmd.exe) directly, but when installed to run as LOCALSYSTEM, output and error redirection didn't work. 我最近遇到一个问题,如果我直接执行该进程(cmd.exe),则可以正常工作,但是当安装为以LOCALSYSTEM的身份运行时,输出和错误重定向均无效。 After a day or so, I figured out that if I also redirect stdin, things work fine. 大约一天后,我发现如果我也重定向标准输入,一切正常。 I found a related thread here , but no real resolution. 我在这里找到了一个相关的线程,但是没有真正的分辨率。

Anyway, I was wondering if anyone knows the reason for this and are there known issues with output in Windows Services? 无论如何,我想知道是否有人知道原因,并且Windows Services中的输出是否存在已知问题?

One complication is that I recently installed W7 SP1, so I'm not sure if this changed the behavior or not since I haven't had a chance to uninstall and try again. 一个复杂的问题是我最近安装了W7 SP1,所以我不确定这是否改变了行为,因为我没有机会卸载并重试。

The standard streams are only available to processes that are running interactively. 标准流仅适用于以交互方式运行的进程。 Windows Services do not run in interactive mode. Windows服务不能以交互模式运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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