Shutdown a remote computer connected in LAN in any preferable language

后端 未结 7 2055
逝去的感伤
逝去的感伤 2021-01-21 19:29

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

相关标签:
7条回答
  • 2021-01-21 20:26

    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

    0 讨论(0)
  • 2021-01-21 20:27

    From a linux box [net rpc shutdown]

    or call initiateSystemShutdown

    0 讨论(0)
  • 2021-01-21 20:29

    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.

    0 讨论(0)
  • 2021-01-21 20:31

    Invoke shutdown -s -m \\computername command through a primitive used to start processes (like Process.Start() or CreateProcess()).

    0 讨论(0)
  • 2021-01-21 20:32

    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

    0 讨论(0)
  • 2021-01-21 20:34

    Not sure if this code sample works, but it illustrates how you can use WMI to remotely shutdown a computer.

    0 讨论(0)
提交回复
热议问题