开发者

How to control network client pc

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开发者_StackOverflow" 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."


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜