首先添加对 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 
   { 
    
   } 
新闻热点
疑难解答