WMI Execution Remote file (RPC)

Source: Internet
Author: User

Execute commands on the remote machine via WMI (wmi:windows managementinterface It is possible to access the constituent units of different operating systems (Windows systems) through a common interface, which can be used to efficiently manage remote and local computers.

 Public Static voidExecuteremote (stringServerhostname,stringDomainstringUserName,stringPasswordstringStrcommand,stringpath) {    //connectionoptions Specifies the settings required to generate a WMI connectionConnectionOptions connoption =Newconnectionoptions (); Connoption.username= domain +@"\"+UserName; Connoption.password=password; //Managementpath wraps the path to generate and analyze WMI objectsManagementpath Mngpath=NewManagementpath (@"\\"+ Serverhostname +@"\root\cimv2:win32_process"); Managementscope Scope=NewManagementscope (Mngpath, connoption); Scope.    Connect (); //The objectgetoptions class is the option to specify to get management ObjectsObjectgetoptions objoption =Newobjectgetoptions (); //ManagementClass is a public Information model (CIM) management class that, through members of the class, can access WMI data using a specific WMI ClasspathManagementClass classinstance =NewManagementClass (Scope, Mngpath, objoption); Managementbaseobject Inparams= Classinstance.getmethodparameters ("Create"); //setting command line argumentsinparams["CommandLine"] =@"cmd.exe/c"+ @path +@"-infile"+@strCommand; Managementbaseobject Outparams= Classinstance.invokemethod ("Create", Inparams,NULL);}

RPC cannot access the problem resolution:

Enable firewalls to allow remote logons to netsh firewall set service remoteadmin

WMI Execution Remote file (RPC)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.