Freigeben über


starting a process on a remote machine

Uses your existing credentials, of course, but I wanted to pass along in case others could use this:

ManagementClass processClass = new ManagementClass("\\\\" +

remoteServer + "\\root\\CIMV2:Win32_Process");

ManagementBaseObject inParams = processClass.GetMethodParameters("Create");

inParams["CommandLine"] = program;

ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);

Console.WriteLine("Started process id {0} on server {1}",

outParams["ProcessId"], remoteServer);

Also, Juanya Williams (lead on the Passport team) mentions the mgmtclassgen tool which can generate strongly-typed wrapper classes.

Comments

  • Anonymous
    October 30, 2004
    Sweeeeet....
  • Anonymous
    October 31, 2004
    The comment has been removed