-1

In vb.net I have used process.start to open a .exe file and then have a threading.thread.sleep after it for an amount of time. Then I want it to close the .exe file but it won't let me use process.kill/close.

code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Process.Start("notepad.exe")
    Threading.Thread.Sleep(2000)
    Process.Kill()
gre_gor
  • 6,669
  • 9
  • 47
  • 52
Selene
  • 31
  • 6

1 Answers1

1

You need to you the object which is referencing the handle for process. here is the example

Dim p As Process = Process.Start("notepad.exe")
p.Kill()
sumeet kumar
  • 2,628
  • 1
  • 16
  • 24