首先添加对 System.Management的引用
然后代码入下:
ConnectionOptions op = new ConnectionOptions ( ) ; 
   op.Username ="wgscd";’或者你的帐号(注意要有管理员的权限)
   op.Password = "wgscd" ; ’你的密码
   ManagementScope scope = new ManagementScope( "\\\\" + "106.54.20.1" + "\\root\\wgscd", 
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-23
  • 2021-08-15
  • 2021-12-02
猜你喜欢
  • 2022-02-20
  • 2021-09-04
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案