如何让服务在当前用户的会话下运行进程? [英] How can I have a service run a process under the current user's session?

查看:103
本文介绍了如何让服务在当前用户的会话下运行进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用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?

推荐答案

如果该服务需要以当前用户身份运行,那么为什么要使其成为一项服务?服务的目的是始终运行,即使用户未登录也是如此.因此,该服务旨在始终以特定用户身份运行.

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?

这篇关于如何让服务在当前用户的会话下运行进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆