Can some one has a little time to explain to me
I have 2 computers in network i want to make a program in c# to shut down a computer in local area network
I want to create a server side program and a client the server sends a command to the client application and the client executes, but i dony know anything about network in c#, can anyone explain how should i make the client listen to a port for command and how should the server send the command
Example:
|server| sends----> My Command(Shutdown the computer) ----> Client recives the command and shut down
Please I really need your help Pleaseee I really do Thanks A lot

Please i really need help In C# network
dogdogkit
You might be able to, but I forsee security problems. With the WMI Classes you can impersonate an admin account to do the proces cleanly. Anoher thing that the WMI Reboot offers is the ability to force a shutdown, or ask the user to close all processes as the machine is shutting down.
kevin_i_orourke
cant you just spawn a
"shutdown \\computername"
from a process
Lappu
hellow i did manage to a good example of this, i thank you all, for your help
If some one need it Here is The code!! i found its really good and works :
http://www.developerfusion.co.uk/show/3918/1/
BTW when i send a command i send it like a text for example : @#$down or play music and in the client i specifie what to do when if that text arrives
Yoni Hemi
With this example you do not have to create both client and server applications becuase there are built in functions that can be used. What you are able to do is to utilize the WMI framework (Windows management Interface), wth this you can do lots of things to various machines. I use these functions (Using VBScript) to manage my remote machines. You can collect information as well as perform tasks like installing software stoping and restarting services, as well as rebooting machines.
I do not have a example of the script here but if you go to the technet scripting center you can get all the scripts that you wil need. When converting them to run in managed code make sure that you add a reference to the system.management classes.
Thuyen Tran
to do such an operation to shutdown a computer, your probably best just making a batch file and running the shutdown command in Windows on the destination PC on a scheduler.
But the way to do it is to use the TCPClient and TCPListner class.
Read the MSDN Documentation, the parameters for these classes are really self explanitory.
You establish a connection to the Server giving it the IP/Port
Once successfully established, send a command.
Close connection
The Server "listens" for the connection, and then you should have a method to recieve the data.
Server:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemnetsocketstcplistenerclasstopic.asp
Client:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemnetsocketstcpclientclasstopic.asp
hope it helps :-)