Remote restart computer (C #)

xiaoxiao2021-03-06  41

Remote restart computer (C #) First add a reference to System.Management, then enter the code: ConnectionOptions op = new connectionOptions (); op.username = "wgscd"; or your account (note must have administrator) OP .Password = "wgscd"; 'Your password 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 "); managementObjectsearchObjectSearcher (Scope, OQ); // Get WMI Control ManagementObjectCollection QueryCollection1 = query1.get ();

Foreach (ManagementObject Mobj IN QueryCollection1) {string [] str = {"}; mobj.invokemethod (" reboot ", str);}} catch {}

转载请注明原文地址:https://www.9cbs.com/read-54237.html

New Post(0)