如何控制网络客户端电脑

发布于 2024-10-18 21:17:43 字数 1387 浏览 0 评论 0原文

在我的本地网络中,我有超过10台电脑。我需要照顾所有电脑。我想知道所有电脑的硬件信息。我也想控制这些电脑,假设,此时此刻我想重新启动我的一台客户端电脑。在 C# 中是否可能。如果有任何问题请询问。提前致谢 我使用以下语法来执行命令。

try
{
    // create the ProcessStartInfo using "cmd" as the program to be run,
    // and "/c " as the parameters.
    // Incidentally, /c tells cmd that we want it to execute the command that follows,
    // and then exit.
    System.Diagnostics.ProcessStartInfo procStartInfo = 
        new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "shutdown /r /m \\172.16.1.3 /t 1 /");

    // The following commands are needed to redirect the standard output.
    // This means that it will be redirected to the Process.StandardOutput StreamReader.
    procStartInfo.RedirectStandardOutput = true;
    procStartInfo.UseShellExecute = false;

    // Do not create the black window.
    procStartInfo.CreateNoWindow = true;

    // Now we create a process, assign its ProcessStartInfo and start it
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo = procStartInfo;
    proc.Start();

    // Get the output into a string
    string result = proc.StandardOutput.ReadToEnd();

    // Display the command output.
    Console.WriteLine(result);
}
catch (Exception objException)
{
    // Log the exception
}

使用上面的代码我收到消息“找不到网络路径。”

In my local network ,I have more than 10 pc.I need to take care all of the pc.I want to know all pc’s hardware informations.I also want to control those pc,Suppose ,at this moment I want to restart one of my client pc.Is it possible in C#.if have any question plz ask.Thanks in advance
I use bellow syntax to execute command.

try
{
    // create the ProcessStartInfo using "cmd" as the program to be run,
    // and "/c " as the parameters.
    // Incidentally, /c tells cmd that we want it to execute the command that follows,
    // and then exit.
    System.Diagnostics.ProcessStartInfo procStartInfo = 
        new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "shutdown /r /m \\172.16.1.3 /t 1 /");

    // The following commands are needed to redirect the standard output.
    // This means that it will be redirected to the Process.StandardOutput StreamReader.
    procStartInfo.RedirectStandardOutput = true;
    procStartInfo.UseShellExecute = false;

    // Do not create the black window.
    procStartInfo.CreateNoWindow = true;

    // Now we create a process, assign its ProcessStartInfo and start it
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo = procStartInfo;
    proc.Start();

    // Get the output into a string
    string result = proc.StandardOutput.ReadToEnd();

    // Display the command output.
    Console.WriteLine(result);
}
catch (Exception objException)
{
    // Log the exception
}

Using the above code I get the message "The network path was not found."

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

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

发布评论

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

评论(3

我也只是我 2024-10-25 21:17:43

请检查网址。
http://support.microsoft.com/kb/317371

如果您想制作一个程序你可以获取远程系统信息。你必须使用微软的Remoting。在这里我们可以在远程系统中创建一个对象,并且我们可以控制它。

可以通过执行System.Diagnostics.ProcessStartInfo来获取系统信息。

可以使用“systeminfo”获取系统信息。可以使用 C# 获取输出,

请检查 这个
我希望这对你有用。

Pls check the url.
http://support.microsoft.com/kb/317371

If you want to make a program which u can able to get the remote system information. You have to use Microsoft's Remoting.Here we can able to create an object in the remote system and we can able to control it.

It is possible to get System's information by executing the System.Diagnostics.ProcessStartInfo.

It is possible to get system information using "systeminfo" .It is possible to take the output using C#

Pls chk the this.
I hope this will be useful for you.

只是我以为 2024-10-25 21:17:43

我不认为这是一个 C# 问题,因为使用 组策略编辑器系统管理服务器System Center Operations Manager 等。

执行一些简单的任务对于远程计算机,您可以查看 PsTools

I don't think this is a C# question, cause this can be done much more elegant with things like Group Policy Editor, System Management Server, System Center Operations Manager, etc.

To do some simple tasks on a remote machine you can take a look into the PsTools.

昵称有卵用 2024-10-25 21:17:43

有了这些要求,我的第一站将是 WMI。例如,有 Win32_OperatingSystem 类其 RebootShutdown 方法以及 Win32_Processor 包含有关 CPU 的各种信息。

此 MSDN 部分向您展示如何从 .Net 使用它:开始访问 WMI 数据< /a>

这个 MSDN 部分有很多简短的 VBScript 示例,用于使用 WMI 执行各种操作,即使代码不同,至少您可以看到应该查看哪些 WMI 类/方法/属性:脚本和应用程序的 WMI 任务

请注意 RB 的评论不过,您需要拥有正确的权限才能使其工作。

编辑:忘记了,因为您需要连接到其他计算机,所以此示例将很有用: 如何:连接到远程计算机

With those requirements my first stop would be WMI. There's for example the Win32_OperatingSystem class with its Reboot and Shutdown methods and the Win32_Processor with all kinds of information about the CPU.

This MSDN section shows you how to use it from .Net: Getting Started Accessing WMI Data

This MSDN section has quite a lot of short VBScript samples for doing various things using WMI, and even if the code is different, at least you can see which WMI classes/methods/properties you should be looking at: WMI Tasks for Scripts and Applications

Please note RB's comment though, you'll need to have the correct permissions for it to work.

Edit: Forgot that since you'll want to connect to other computers, this sample will be useful: How To: Connect to a Remote Computer

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