private void button1_Click ( object sender , System.EventArgs e )
 {
 //定义连接远程计算机的一些选项
 ConnectionOptions options = new ConnectionOptions ( ) ;
 options.Username = textBox2.Text ;
 options.Password = textBox3.Text ;
 ManagementScope scope = new ManagementScope( "\\\\" + textBox1.Text + "\\root\\cimv2", options ) ;
 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 mo in queryCollection1 ) 
 {
 string [ ] ss= { "" } ;
 //重启远程计算机
 mo.InvokeMethod ( "Reboot" , ss ) ;
 }
 }
 //报错
 catch ( Exception ee ) {
 MessageBox.Show ( "连接" + textBox1.Text + "出错,出错信息为:" + ee.Message ) ;
 }
 }
 }