how to close the window generated by an process(for msinfo32) after it exits

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paragshravagi
    New Member
    • Mar 2008
    • 3

    how to close the window generated by an process(for msinfo32) after it exits

    Hi.
    I am trying to open a process for msinfo32.exe using C#.
    I successfully started it.

    But after that I need to wait for 10 seconds for some other operations during which this process gets exited.

    After this, I want to close the "System Information" window generated by this process.

    I tried using processInstance .CloseMainWindo w(), but I get the exception as "No process associated with this object".

    The code snippet is :


    Code:
    using System.Diagnostics;
    ......
    
    Process processInstance = new Process();
    processInstance.StartInfo.FileName = "msinfo32";
    processInstance.Start();
    
    //some other processing goes on here during which this process exits.
    //I have used Thread.Sleep to simulate the condition.
    Thread.Sleep(10000);
    
    //both of these give exception
    processInstance.Kill();  //OR
    processInstance.CloseMainWindow();
    
    //this works fine but the system information window remains open.
    processInstance.Close();

    Thanks for help in advance.
    ParagS.
    Last edited by Plater; Mar 14 '08, 01:10 PM. Reason: code tags
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I would guess that when you run that process it really opens it's another process withen itself?
    Like you run process A, and processAs only job is to (secretly?) open processB.
    ProcessB is the window you see, but you only have control to close processA.

    You might have to do a Process.GetAllP roccess() (or whatever) and find the one you want and kill it that way?

    Comment

    • paragshravagi
      New Member
      • Mar 2008
      • 3

      #3
      Thanks for your help plater.

      It works in the way you explained. It starts HelpCtr.exe process internally.
      I closed it explicitly and I am done.

      Comment

      Working...