是否有可能通过编程.NET应用程序要关闭“远程电脑”? [英] Is it possible to Shut down a 'remote PC' programatically through .net application?

查看:176
本文介绍了是否有可能通过编程.NET应用程序要关闭“远程电脑”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关闭连接在局域网中的任何要求懂


我想知道,是否有可能通过.NET应用程序编程关闭远程PC?

I am wondering, Is it possible to Shut down a remote PC programatically through .net application?

如果是的,这怎么可能呢?

If yes, how it can be?

推荐答案

请参阅< A HREF =htt​​p://support.microsoft.com/kb/317371相对=nofollow>此知识库文章

例如:

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName = "shutdown.exe";
proc.StartInfo.Arguments = @"\\computername /t:120 ""The computer is shutting down"" /y /c";
proc.Start();



上面的例子使用下面的开关(从链接的文章中摘录)

The example above uses the following switches (excerpted from the linked article)


  • \\computername:使用此开关指定远程计算机关机。如果省略此参数,将使用本地计算机名称

  • \\computername: Use this switch to specify the remote computer to shut down. If you omit this parameter, the local computer name is used.

/吨:xx:此开关指定时间(以秒为单位)之后,电脑关机。默认为20秒。

/t:xx: Use this switch to specify the time (in seconds) after which the computer is shut down. The default is 20 seconds.

计算机正在关闭:使用此开关在关机过程中指定的消息。 。该消息可以包含的最多字符数为127

"The computer is shutting down": Use this switch to specify a message during the shutdown process. The maximum number of characters that the message can contain is 127.

/ y:此开关来强制是回答所有查询从电脑

/y: Use this switch to force a "yes" answer to all queries from the computer.

/ c:此开关用于退出所有正在运行的程序。如果您使用此开关,Windows将强制所有正在运行的程序退出。该选项来保存,可能已经改变了被忽略的任何数据。这可能会导致在其数据没有被预先保存的程序的数据丢失。

/c: Use this switch quit all running programs. If you use this switch, Windows forces all programs that are running to quit. The option to save any data that may have changed is ignored. This can result in data loss in any programs for which data is not previously saved.

这篇关于是否有可能通过编程.NET应用程序要关闭“远程电脑”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆