.NET类来控制服务在远程计算机上? [英] .Net classes to control services on a remote machine?

查看:191
本文介绍了.NET类来控制服务在远程计算机上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我可以google一下,但我是一个懒一点。我需要另一台机器上远程控制Windows服务。是否ServiceController的类让我做到这一点?有没有什么限制?我可以启动/停止/改变远程运行方式的详细信息,如更改密码,这是到期?

我将试图给用户在工作中ASP.Net网站的仪表板来控制自己的账户(他们自己的机器上的所有本地管理员)的本地计算机上运行的若干服务。这是所以我不看创造能为他们在本地运行分发与其他功能集成在一起。将使用Windows身份验证和模拟用户进行更改。如果有的话是什么问题,我有可能利用此碰上?

干杯


解决方案

  VAR SC =新的ServiceController(服务名,othermachinename);

运行code中的帐户需要以与服务交互目标计算机的管理权限。模拟会工作。我只用这一个相当严格控制的情况下(即从在源/目标机器相同凭据的用户帐户下运行),但在我的经验中所有操作正常工作。

如果您想更改服务凭据等,你将不得不使用WMI - 这是不是因为使用ServiceController的类一样容易。见的ManagementObject类以获取更多信息。

我发现,描述使用WMI更改服务这个环节凭据。

Yes I could google this but I'm being a little lazy. I need to remotely control windows services on another machine. Does the ServiceController class let me do this? What restrictions are there? Can I start / stop / change the "run as" details remotely, ie change a password that's due to expire?

I'll be attempting to give users at work a ASP.Net website dashboard to control several services that run on their local machine under their own account (they're all local administrators on their machine). This is integrated with other functionality so I'm not looking at creating a distributable that could run locally for them. Will be using windows authentication and impersonating the user to make the changes. What problems if any am I likely to run into with this?

Cheers

解决方案

var sc = new ServiceController("servicename", "othermachinename");

The account running the code will need administrative permissions on the target computer in order to interact with the service. Impersonation will work. I've only used this in a fairly tightly-controlled situation (i.e. running from a user account with the same credentials on the source/target machines), but in my experience all operations work as expected.

If you want to change service credentials etc, you'll have to use WMI -- which is not as easy as using the ServiceController class. See the ManagementObject class for more information.

I found this link that describes using WMI to change service credentials.

这篇关于.NET类来控制服务在远程计算机上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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