C# WMI start remote process with delay RRS feed

  • Question

  • Hi,

    My program (C#) must create a remote process and return the exit_code when it's finished.

    Because I want to do this programmatically without using PsExec, I use "InvokeMethod("create"... from ManagementBaseObject class and then I use a ManagementEventWatcher class to get the "stop" event.

    It works but...

    If the remote command finishes quickly, I mean before my watcher is listening ; I'm not able to get the exit_code.

    So, is there a way to execute a remote process with a delay before runtime in order to let the watcher run before the command execution?

    I tried with a ProcessStartupInformation with 4 in the property "CreateFlag". Then the remote process is created in a suspend status but I never find a way to resume the remote thread. If somebody knows a solution to do that, it could be very very helpfully... It seems that "AttachDebugger" method is another way to suspend a remote process but I don't know how to "detachDebugger".

    Let me know if my explanations are not clear.


    • Moved by Cleber Marques MSFT Thursday, June 23, 2011 11:50 AM (From:Microsoft Operations Framework -- MOF 4.0)
    Monday, June 20, 2011 1:58 PM

All replies

  • Sorry, but you have posted your question in a forum that talk about Microsoft Operations Framework (MOF), then I am moving your post to another forum and I hope you can get some help. But if you want you can try to find other forum by yourself:




    Hope that helps



    Cleber Marques

    Microsoft MVP & MCT | Charter Member: SCVMM & MDOP
    MOF Brazil Project: Simplifying IT Service Management
    My Blog | MOF.com.br | CleberMarques.com | CanalSystemCenter.com.br

    Thursday, June 23, 2011 11:49 AM
  • We have gone through the document of both ManagementBaseObject and ManagementEventWatcher classes. We need to develop a sample application to create an application to invoke a remote process using the ManagementBaseObject class and to make a watcher using ManagementEventWatcher class. After creating such an application then we can research whether it’s possible to keep the watcher until we get exit_code from the remote process. This process will take some time. From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.

    --Trevor H.
    Send files to Hotmail.com: "MS_TREVORH"
    Wednesday, June 29, 2011 10:02 PM