start / stop process

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tascien@gmail.com

    #1

    start / stop process

    Hi guys, I would like to be able to open a program and close it wright
    within vb...

    ' this one works...
    Process.Start(" c:\someProgram. exe")

    Thread.sleep(50 00)

    ' this one doesn't !
    Process.Stop()

    how can I do the second? any ideas?

  • Morten Wennevik [C# MVP]

    #2
    Re: start / stop process

    Hi Tacien,

    Keep a reference to the process when you start it.

    Process p = Process.Start(" Notepad.exe");

    You can then, call CloseMainWindow () for windows application or Kill() to
    end the process.

    p.CloseMainWind ow();

    or

    p.Kill();

    --
    Happy Coding!
    Morten Wennevik [C# MVP]

    Comment

    Working...