I want to shut down the remote computer (ex. a computer connected in LAN.) I have tried a lot but I could not find the solution. Does anyone have an idea on how to shut down the remote computer? Any language would work.
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
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.
Not sure if this code sample works, but it illustrates how you can use WMI to remotely shutdown a computer.
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
- Connect to the host through SSH
- user@domain:~$ sudo shutdown -h now
From a linux box [net rpc shutdown
]
or call initiateSystemShutdown