V
Vivek
Hello,
I am trying to create a process on a remote machine. I am able to
successfully do so but i cant get the process to show its window. I can see
it running in Task Manager. I have tried setting the processStartup
parameter to 1, 5 etc. but to no avail. Could someone help please?
Thanks
Vivek
Heres my code:
public bool StartProcessByName1(string ProcessName)
{
string Path = string.Format(@"\\{0}\root\cimv2",SystemName);
ManagementScope ms = new ManagementScope(Path);
ManagementPath ProcessMgmtpath = new ManagementPath( "Win32_Process");
ManagementClass processClass = new ManagementClass(ms,ProcessMgmtpath,null);
ManagementPath ProcessStartupMgmtpath = new
ManagementPath("Win32_ProcessStartup");
ManagementClass processStartupClass = new
ManagementClass(ms,ProcessStartupMgmtpath,null);
processStartupClass.SetPropertyValue("ShowWindow", 1);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = ProcessName;
inParams["ProcessStartupInformation"] = processStartupClass;
ManagementBaseObject ReturnObj =
processClass.InvokeMethod("Create",inParams,null);
return (ReturnObj["returnValue"].ToString() == "0");
}
I am trying to create a process on a remote machine. I am able to
successfully do so but i cant get the process to show its window. I can see
it running in Task Manager. I have tried setting the processStartup
parameter to 1, 5 etc. but to no avail. Could someone help please?
Thanks
Vivek
Heres my code:
public bool StartProcessByName1(string ProcessName)
{
string Path = string.Format(@"\\{0}\root\cimv2",SystemName);
ManagementScope ms = new ManagementScope(Path);
ManagementPath ProcessMgmtpath = new ManagementPath( "Win32_Process");
ManagementClass processClass = new ManagementClass(ms,ProcessMgmtpath,null);
ManagementPath ProcessStartupMgmtpath = new
ManagementPath("Win32_ProcessStartup");
ManagementClass processStartupClass = new
ManagementClass(ms,ProcessStartupMgmtpath,null);
processStartupClass.SetPropertyValue("ShowWindow", 1);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = ProcessName;
inParams["ProcessStartupInformation"] = processStartupClass;
ManagementBaseObject ReturnObj =
processClass.InvokeMethod("Create",inParams,null);
return (ReturnObj["returnValue"].ToString() == "0");
}