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 restart Remote Computer {public partial class form1: FORM {public form1 () {initializecomponent ();} private void btn_reboot_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 = "deregister") // {// Mo. invokemethod ("logoff", SS); // }}} catch (exception ER) {MessageBox. show ("connection" + textbox1.text + "error, error message:" + er. message) ;}} private void form=load (Object sender, eventargs e) {combobox1.items. add ("restart"); combobox1.items. add ("Disable computer"); // combobox1.items. add ("logout ");}}}