1、必须知道管理员用户名和密码
2、确认远程PC机启动了RPC服务

添加引用System.Management
using System.Management;

private void RebootPc()
        {
            ConnectionOptions op = new ConnectionOptions ( ) ;
            op.Username ="Administrator";   //拥有管理员权限的用户名
            op.Password = "111" ;           //密码
            ManagementScope scope = new ManagementScope("\\\\" + "192.168.123.186" + "\\root\\cimv2", op);
            try
            {
                scope.Connect( ) ;
                System.Management.ObjectQuery oq = new System.Management.ObjectQuery ( "SELECT * FROM        Win32_OperatingSystem" ) ;
                ManagementObjectSearcher query1 = new ManagementObjectSearcher ( scope , oq ) ;
                //得到WMI控制
                ManagementObjectCollection queryCollection1 = query1.Get ( ) ;

                foreach ( ManagementObject mobj in queryCollection1 )
                {
                    string [ ] str= { "" } ;
                    mobj.InvokeMethod( "Reboot" , str ) ;
                }
            }
            catch
            {

            }

        }

相关文章:

  • 2022-12-23
  • 2022-02-21
  • 2021-12-24
  • 2021-12-04
  • 2022-12-29
  • 2022-12-23
  • 2021-08-15
猜你喜欢
  • 2022-02-20
  • 2022-02-14
  • 2021-09-04
  • 2022-12-23
相关资源
相似解决方案