windows 以任何首选语言关闭 LAN 中连接的远程计算机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/685528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Shutdown a remote computer connected in LAN in any preferable language
提问by sivakumar
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 shut down the remote computer? Any language would work.
我想关闭远程 Windows 计算机(例如连接在 LAN 中的 Windows 计算机。)我尝试了很多但找不到解决方案。有没有人知道如何关闭远程计算机?任何语言都可以。
回答by Rob Stevenson-Leggett
Assuming a windows box.
假设一个窗口框。
In VB.NET or c#
在 VB.NET 或 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
请参阅
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
编辑:注意 -shutdown.exe
仅在 Windows 2003 之前的资源工具包中可用
回答by Jakob Christensen
You can connect to any computer on the domain and shut it down using the Win32Shutdownmethod of the WMI class Win32_OperatingSystem. In .NET you access WMI through the System.Managementnamespace.
您可以连接到域中的任何计算机并使用WMI 类 Win32_OperatingSystem的Win32Shutdown方法将其关闭。在 .NET 中,您可以通过System.Management命名空间访问 WMI 。
回答by sharptooth
Invoke shutdown -s -m \\computernamecommand through a primitive used to start processes (like Process.Start() or CreateProcess()).
通过用于启动进程的原语(如 Process.Start() 或 CreateProcess())调用shutdown -s -m \\computername命令。
回答by phatoni
If the remote computer is a Windows box you can use WMI (Windows Management Instrumentation).
如果远程计算机是 Windows 机器,您可以使用 WMI(Windows Management Instrumentation)。
http://msdn.microsoft.com/en-us/library/aa394582.aspx
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
使用 Win32_OperatingSystem 类的 Reboot() 方法。例如,您可以使用 Windows Script、C#、VB .net 执行此操作
回答by reedwolf
- Connect to the host through SSH
- user@domain:~$ sudo shutdown -h now
- 通过SSH连接主机
- user@domain:~$ sudo shutdown -h 现在
回答by Brad Gilbert
回答by Topilski Alexandr
Good day, not a language but can be interested for you: http://www.siteonyourdevice.com/templates/shutdown template.
美好的一天,不是一种语言,但可以对您感兴趣:http: //www.siteonyourdevice.com/templates/关机模板。
How it works:
1) You register new account.
2) Register domain which you want.
3) Download client.
4) Install and start client, specify path in which you download shutdown template, update config file.
5) Open hot link and click shutdown button, after that your computer must shut-downed.
工作原理:
1)您注册新帐户。
2)注册你想要的域名。
3) 下载客户端。
4) 安装并启动客户端,指定下载关机模板的路径,更新配置文件。
5) 打开热点链接并点击关机按钮,之后您的计算机必须关闭。
回答by Topilski Alexandr
Not sure if this code sample works, but it illustrates how you can use WMI to remotely shutdown a computer.
不确定此代码示例是否有效,但它说明了如何使用 WMI 远程关闭计算机。