I want to shut down a remote Windows computer (ex. a Windows computer connected in LAN.) I have tried a lot but I could not find the solution. Does anyone have an idea on how to
If the remote computer is a Windows box you can use WMI (Windows Management Instrumentation).
http://msdn.microsoft.com/en-us/library/aa394582.aspx
Use the Reboot() method of the Win32_OperatingSystem class. You could do this for example using Windows Script, C#, VB .net
From a linux box [net rpc shutdown
]
or call initiateSystemShutdown
You can connect to any computer on the domain and shut it down using the Win32Shutdown method of the WMI class Win32_OperatingSystem. In .NET you access WMI through the System.Management namespace.
Invoke shutdown -s -m \\computername command through a primitive used to start processes (like Process.Start() or CreateProcess()).
Assuming a windows box.
In VB.NET or c#
Process.Start("shutdown","-s -m \\Machine");
Should do the trick.
See
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx
http://www.ss64.com/nt/shutdown.html
EDIT: Note - shutdown.exe
was only available in Resource Kits prior to Windows 2003
Not sure if this code sample works, but it illustrates how you can use WMI to remotely shutdown a computer.