远程重启计算机(C#)
发表于:2007-06-30来源:作者:点击数:
标签:
远程重启计算机(C#) 首先添加对 System.Management的引用 然后代码入下: ConnectionOptions op = new ConnectionOptions ( ) ; op.Username =wgscd;@#或者你的帐号(注意要有管理员的权限) op.Password = wgscd ; @#你的密码 ManagementScope scope = new
远程重启计算机(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 ) ;
//得到W
MI控制
ManagementObjectCollection queryCollection1 = query1.Get ( ) ;
foreach ( ManagementObject mobj in queryCollection1 )
{
string [ ] str= { "" } ;
mobj.InvokeMethod ( "Reboot" , str ) ;
}
}
catch
{
}
原文转自:http://www.ltesting.net