Home > Net >  How to enter the password by wmi remote execution runas
How to enter the password by wmi remote execution runas

Time:11-01

 
ConnectionOptions ops=new ConnectionOptions ();//the new connection option
Ops. The Username="administrator"; The user name//remote machine, hypothesis of Administrator
Ops. Password="test";//the corresponding user name password
Ops. EnablePrivileges=true;
String address="192.168.1.1";//remote machine IP address
ManagementScope scope=new ManagementScope (@ \ \ "" + address + @"/root/cimv2 ops);//create a connection to the remote machine
Scope. The Connect ();
ObjectGetOptions objOption=new ObjectGetOptions ();

//ManagementClass represent common information model (CIM), management class, by members of the class, you can use a specific WMI class path to access the WMI data
ManagementPath mngPath=new ManagementPath (@ \ \ "" + address + @"/root/cimv2: Win32_Process ");
ManagementClass classInstance=new ManagementClass (scope, mngPath objOption); Int ProcessId=0;


//object [0] cmdline={" CMD/c start http://192.168.103.100 "};
Object [] cmdline={" ", ""};
Cmdline [0]="runas/user: administrator " CMD \ "";

//call the method that execute the command

ClassInstance. InvokeMethod (" Create ", cmdline);


C: \ Users \ Administrator> Runas/user: adminstrator CMD
Enter adminstrator password:

Performing the runas will ask for a password, could you tell me how can I through the wmi incoming to enter the password, because want to run on multiple machines may not be able to use the/savecred parameter, wish you a great god can help solve

CodePudding user response:

Mainly is to want to open some distance to the corresponding server application, but need to have the form shows,

CodePudding user response:

Brother, you know, I'm the problem

CodePudding user response:

I have also tried similar scheme, using wmi remote open applications like cannot display window, finally use the remote to create task plan way to open the program,
  •  Tags:  
  • C#
  • Related