如何从 Windows 服务中启动进程

发布于 2024-08-28 04:25:21 字数 282 浏览 1 评论 0原文

我想从 Windows 服务中弹出一个带有给定 URL 的浏览器。像这样:

System.Diagnostics.Process.Start("http://www.venganza.org/");

在控制台中运行时工作正常,但在服务内运行时则不然。没有错误消息,没有异常,Process.Start() 命令似乎什么也没做。有点安全问题的味道,也许是服务属性和/或登录选项的问题?这烦人的东西...有人吗? (哦,还有 Windows 7/.NET Framework 3.5。)

I want to pop a browser with a given url from within a windows service. Like so:

System.Diagnostics.Process.Start("http://www.venganza.org/");

Works fine when running in a console but not from within the service. No error messages, no exceptions, the Process.Start() command just seem to do nothing. It smells of some security issue, maybe something with the service properties and/or logon options? Annoying stuff this... Anybody? (Oh, and on windows 7/.NET framework 3.5.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

删除会话 2024-09-04 04:25:21

服务永远不应该向用户弹出任何内容。不要对服务执行此操作。

您可能还需要更高的权限才能执行此操作。您必须以用户身份登录。

即使你设法做到这一点,也不要这样做。这不是服务的目的,而且这是非常糟糕的做法。如果您确实希望弹出某些内容,请使用单独的过程。

A service should never pop up anything to the user. Don't do this with a service.

You will problably need elevated rights to do this aswell. You will have to sign in as the user.

Even if you manage to do this, don't. This is not what services is ment for and it is really bad practise. If you really want someting to pop up, have a seperate process instead.

呆° 2024-09-04 04:25:21

它正在弹出,但位于与该服务关联的 Window Station 上。

我建议您调整您的设计,以便您的服务不需要以这种方式进行交互。有多种方法可以让它出现在交互式桌面上(您必须处理诸如模拟相关用户、在没有人登录或多个人登录时定位正确的桌面等问题)

It is popping up, but on the Window Station associated with the service.

I would suggest that you tweak your design such that your service doesn't need to interact in this manner. There are ways to get it to appear on an interactive desktop (you'd have to cope with issues such as impersonating the relevant user, targeting the correct desktop if nobody is logged on or if more than one person is logged on, etc.)

ι不睡觉的鱼゛ 2024-09-04 04:25:21

附带说明一下,Windows 服务并不是为交互而构建的。它们用于处理幕后类型的内容。但是,您是否尝试过在服务本身上启用与桌面交互选项?

Just on a side note Windows services aren't built for interactivity. They are used to process behind-the-scenes type stuff. However, have you tried enabling the Interact with Desktop option on the service itself?

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