Quizzes
Using System; using System. collections. generic; using System. componentModel; using System. data; using System. drawing; using System. text; using System. windows. forms; using System. management; namespace remote {public partial class Form1: Form {public Form1 () {InitializeComponent ();} private void button#click (object sender, EventArgs e) {// define some options for connecting to the remote computer ConnectionOptions = new ConnectionOptions (); options. username = textBox2.Text; options. password = textBox3.Text; ManagementScope scope = new ManagementScope ("\\\\" + textBox1.Text + "\\ root \ cimv2", options ); try {// connect to the remote computer scope with the given administrator username and password. connect (); ObjectQuery oq = new ObjectQuery ("select * from win32_OperatingSystem"); descriquery1 = new ManagementObjectSearcher (scope, oq); ManagementObjectCollection queryCollection1 = query1.Get (); foreach (ManagementObject mo in queryCollection1) {string [] ss = {""}; if (comboBox1.Text = "restart") {mo. invokeMethod ("Reboot", ss);} if (comboBox1.Text = "Disable computer") {mo. invokeMethod ("Shutdown", ss);} if (comboBox1.Text = "logout") {mo. invokeMethod ("Logoff", ss) ;}} catch (Exception er) {MessageBox. show ("connection" + textBox1.Text + "error, error message:" + er. message );}}}}
Http://download.csdn.net/detail/carl_xie_87/6853319 program download page
--
24.57