首页 > 开发 > 综合 > 正文

C#简单实现的远程命令程序

2024-07-21 02:25:19
字体:
来源:转载
供稿:网友
注册会员,创建你的web开发资料库,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 processclass = new managementclass(scope,path,o);




managementbaseobject inparams = processclass.getmethodparameters("create");


inparams["commandline"] = commandbox.text;




managementbaseobject outparams = processclass.invokemethod ("create", inparams, null);

}

catch(exception ee)

{

messagebox.show(ee.message,"error");

}

}



private void button2_click(object sender, system.eventargs e)

{

application.exit();

}

}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表