从同一LAN中连接的另一个系统关闭系统 [英] Shutdown system from another system connected with in same LAN

查看:90
本文介绍了从同一LAN中连接的另一个系统关闭系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是

1:创建窗口服务

2:在所有局域网PC上部署



这样做后

1:在winforms中创建一个应用程序

2:调用windows服务方法并关闭电脑



有可能吗?或任何推荐的解决方案?

- > LAN Pc有点对点连接



我尝试过:



我试过管理范围

在所有LAN pc中启用WMI

但是我在management.scope.connect()中遇到异常;



这里是我试过的代码

What i need is
1: Create window serivce
2: deploy on all LAN PC's

after doing so
1: create a app in winforms
2: call windows service method and shutdown that pc

is it possible ? or any recommended solution?
-> LAN Pc have Peer to Peer connection

What I have tried:

I have tried Management scope
Enabled WMI in all LAN pc's
but i got exception in management.scope.connect();

here is code i tried

Process.Start("shutdown","-s -m \\ComputerName or IP");



也尝试了


also tried

ManagementScope scope = new ManagementScope(
          "\\\\" + computerName +  "\\root\\CIMV2", options);
        scope.Connect();

推荐答案

如果不在域中,您仍需提供管理凭据目标机器上的帐户,这是有道理的,因为没有人希望任何人在未经他们同意的情况下关闭他们的计算机。

为此,你可以连接到IPC
Without being in a domain, you still have to provide the credentials of an administrative account on the target machine, which makes sense because nobody wants anybody being able to shutdown their computer without their consent.
For that, you can connect to the IPC


目标计算机上的隐藏共享:

hidden share on the target computer:
net use \\TARGETCOMPUTER\IPC


adminpassword / user:targetcomputer \ admminaccountname
adminpassword /user:targetcomputer\admminaccountname



从这里你可以发出你的关机命令:


From here you will be able to issue your shutdown command:

shutdown -m \\TARGETCOMPUTER



这应该可以解决问题。

亲切。



编辑:您无需为此编写和部署服务,您可以直接从应用程序发出这些命令。 Windows已根据您的要求提供所有必需的服务。


That should do the trick.
Kindly.

You do not need to write and deploy a service for that, you can issue these commands from your application directly. Windows already has all required services for your requirement.


这篇关于从同一LAN中连接的另一个系统关闭系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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