远程重启计算机(C#)

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 wgsnet 的 blog

远程重启计算机(c#)
首先添加对 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
   {
  
   }


 

本文关键:远程重启计算机(C#)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top