C # Simple implementation remote command programs

xiaoxiao2021-03-19  201

Private void Button1_Click (Object Sender, System.Eventargs E)

{

ConnectionOptions Opt = New ConnectionOptions ();

Opt.username = Userbox.Text;

Opt.password = passbox.text;

Managementscope scope = new managementscope (" ipbox.text " // root // CIMv2 ", OPT);

Try

{

Scope.connect ();

ObjectgetOptions o = new objectGetoptions ();

ManagementPath Path = New ManagementPath ("Win32_Process");

ManagementClass ProcessClassClass (Scope, Path, O);

ManagementBaseObject INPARAMS = ProcessClass.getMethodparameters ("create");

INPARAMS ["CommandLine"] = CommandBox.Text;

ManagementBaseObject Outparams = ProcessClass.InvokeMethod ("Create", INPARMS, NULL);

}

Catch (Exception EE)

{

Messagebox.show (Ee.Message, "Error");

}

}

Private void button2_click (Object Sender, System.Eventargs E)

{

Application.exit ();

}

}

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

New Post(0)