如何让服务在当前用户会话下运行进程?

发布于 2024-10-31 23:04:36 字数 215 浏览 6 评论 0原文

我有一个用 C# 编写的服务,用于监视一组文件。如果这些文件之一的修改时间超过 4 小时,它会使用 Growl 通知最终用户。我见过 Growl.exe 没有在当前用户会话下运行的情况,因此它们没有收到更新。我希望我的服务能够检查以确保 Growl 正在运行(Growl.exe 或者我可以在某处查找应用程序 ID?),如果没有运行则启动它。如何确保 Growl 始终在运行此服务的任何计算机上的当前用户会话中运行?

I have a service, written in C#, that monitors a set of files. It uses Growl to notify the end-user if the modified time of one of these files is over 4 hours old. I've seen situations where Growl.exe was not running under the current user's session, thus they did not receive updates. I'd like my service to check to make sure Growl is running (either Growl.exe or maybe I could look for the application ID somewhere?) and start it if it's not. How can I ensure that Growl is always running in the current user's session on any machine that this service runs on?

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

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

发布评论

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

评论(3

红尘作伴 2024-11-07 23:04:36

如果服务需要以当前用户身份运行,那为什么要把它变成一个服务呢?服务的目的是始终运行,即使用户未登录也是如此。因此,它被设计为始终以特定用户身份运行。

为什么不将其转换为用户登录时运行的程序?

If the service needs to run as the current user, then why make it a service? The purpose of a service is to run at all times, even when a user is not logged in. As such, it's designed to run as a specific user at all times.

Why not convert this to a program that runs when a user logs in?

薄情伤 2024-11-07 23:04:36

这是一个有趣的问题,但似乎您不能像这篇文章那样执行此操作 建议。似乎您可以指定该服务作为本地系统服务运行,或者作为特定用户运行:

Service Dialog

It's an interesting question, but it would appear that you can't do this as this post suggests. It seems like you can either specify that the service runs as a local system service, or as a particular user:

Service Dialog

够运 2024-11-07 23:04:36

如果您的服务以“自动”方式启动,那么您只能为该服务预先配置一组凭据。但是,如果您可以识别该服务在启动时调用的 .exe 文件,那么您可以创建一个批处理文件,该文件将在登录时启动该服务,此时将默认使用活动用户凭据。

干杯,

CEC

If your service is being started as "automatic" then you may only pre-configure a single set of credentials for the service. However, if you can identify the .exe file that the service is invoking at startup then you can create a batch file that will kick off that service at logon, at which point the active users credentials will be used by default.

Cheers,

CEC

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