是否可以登录谁开始或停止一个窗口服务? [英] Is it possible to log who started or stopped a windows service?

查看:131
本文介绍了是否可以登录谁开始或停止一个窗口服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些窗口在C#编写的服务。当某人停止或启动该服务,我希望能够确定是谁和日志信息。

I have some windows services written in C#. When somebody stops or starts the service, I would like to be able to determine who it was and log that information.

我试图登录环境。用户名,但计算结果为系统,即使在我的本地机器上。

I tried logging Environment.UserName but that evaluates to SYSTEM even on my local machine.

此外,对于目前这些服务在Windows 2000服务器上运行。

Also, for the time being these services are running on Windows 2000 server.

推荐答案

在事件查看器(控制面板|管理工具|事件查看器)系统选项卡上的服务控制管理器日志谁开始,停止每个事件。我刚刚测试了这个自己和观察结果。这使我两件事情:

Within the Event Viewer (Control Panel | Administrative Tools | Event Viewer) on the System tab the Service Control Manager logs who started and stop each event. I've just tested this myself and viewed the results. This leads me to two things:


  1. 您可能能够查询或钩从服务控制管理器的事件,因为它们发生,或

  2. 您绝对可以只查询事件查看器中的系统登录到寻找这些事件为您服务。

希望带您到您的解决方案。

Hope that leads you to your solution.

这篇关于是否可以登录谁开始或停止一个窗口服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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