Starting a Process

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dschu012
    New Member
    • Jul 2008
    • 39

    Starting a Process

    When using the following code
    Code:
    p = Process.Start("firefox", "-new-window http://google.com/");
    p.WaitForInputIdle();
    MessageBox.Show(p.HasExited.ToString());
    The p.HasExited is always true and I can't get any more info from the process. I want to be able to get the MainWindowTitle and the MainWindowHandl e but I can't figure out a way to do this because if I try to it says the process has exited.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    It may never hit the InputIdle state until the process has closed.

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      Is there an asynchronous start method?

      Comment

      • dschu012
        New Member
        • Jul 2008
        • 39

        #4
        Dont know exactly what you guys mean I am kind of a noob at this stuff but is this the way I should be approaching starting a process and being able to get the Handle of the main window of a process or is there a better way?

        Comment

        • vekipeki
          Recognized Expert New Member
          • Nov 2007
          • 229

          #5
          Your problem is that you probably have another Firefox window already open. In that case, your new process will just notify the first process instance and die immediately.

          Try to open several Firefox windows, and then check Process.GetProc essesByName("fi refox"); - it will return only a single Process instance. Also try to test your program with all firefox windows initially closed.

          What is it exactly you are trying to do? It doesn't seem like you want to open an instance of Firefox just to get its main window name, so maybe there is something else you could do?

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            firefox doesn't seem to like letting you open up an actual other process. (Unless you switch profiles with the -P (profilename) command argument)

            Comment

            • dschu012
              New Member
              • Jul 2008
              • 39

              #7
              Originally posted by Plater
              firefox doesn't seem to like letting you open up an actual other process. (Unless you switch profiles with the -P (profilename) command argument)
              yeah I've noticed that. But anyways I was trying to get the Handle of the process so I could use PostMessage from Win32 API to automate some tasks without the browser being active. However I have seemed to have gotten the same thing accomplished with the webBrowser control and without using PostMessage.

              Comment

              Working...