简体   繁体   English

如何使用 C#.net 关闭 Remote PC?

[英]How to shutdown Remote PC using C#.net?

I wanted my application to shutdown the remote PC on a button click event.我希望我的应用程序在按钮单击事件时关闭远程 PC。 How can i achieve such heights?我怎样才能达到这样的高度?

I don't want to use telnet or any process to occur in the remote computer.我不想在远程计算机上使用 telnet 或任何进程。 Please guide me in C#.net programming interface.请在 C#.net 编程界面中指导我。

You'll have to call the Win32 API.您必须调用 Win32 API。 Take a look to InitiateSystemShutdowEx看看InitiateSystemShutdowEx

If you never worked with interop, here you have the code to call this method from .NET.如果您从未使用过互操作,这里有从 .NET 调用此方法的代码。 InitiateSystemShutdownEx PInvoke InitiateSystemShutdownEx PInvoke

However, take into account that you will need some elevated privileges...但是,请考虑到您将需要一些提升的权限...

The easiest way will be to call the shutdown command with the appropriate parameters.最简单的方法是使用适当的参数调用关闭命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM