CreateProcess not showing window

From: Vivek (v_mangal_at_hotmail.com)
Date: 09/24/04


Date: Fri, 24 Sep 2004 14:34:27 -0700

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");

}



Relevant Pages

  • CreateProcess not showing window
    ... I am trying to create a process on a remote machine. ... successfully do so but i cant get the process to show its window. ... ManagementClass processClass = new ManagementClass; ... ManagementBaseObject ReturnObj = ...
    (microsoft.public.win32.programmer.wmi)
  • Re: execute program on remote PC
    ... ConnectionOptions options = new ConnectionOptions; ... ManagementClass processClass = new ... The .cmd and .bat files are associated with Cmd.exe so you do not need to ... then add userid to the admin group on the remote machine and try again. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: execute program on remote PC
    ... do i substitute notepad.exe with xxx.bat if i want to run a batch file ... then add userid to the admin group on the remote machine and try again. ... ManagementClass processClass = new ...
    (microsoft.public.win32.programmer.wmi)