I want to start a process on a remote Machine using WMI but the Create method can't be used for remote connections? P.S : I don't want to use PsTools
Here's a sample of the code :
ConnectionOptions connectoptions = new ConnectionOptions();
connectoptions.Username = "";
connectoptions.Password = "";
//IP Address of the remote machine
string ipAddress = "";
ManagementScope scope = new ManagementScope(@"\\" + ipAddress + @"\root\cimv2");
scope.Options = connectoptions;
//Define the WMI query to be executed on the remote machine
SelectQuery query = new SelectQuery("select * from Win32_Process");
using (ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query))
{
ManagementObjectCollection collection = searcher.Get();
foreach (ManagementObject process in collection)
{
object[] theProcessToRun = { "notepad.exe" };
process.InvokeMethod("Create", theProcessToRun );
}
}