Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ending Unmanaged Processes

Status
Not open for further replies.

DwaineC

MIS
Jan 6, 2003
40
0
0
US
If I initialize an Excel Application object, do my thing, then app.quit, it still shows up under the Task Manager processes. Any idea how to endProcess a Process running under Task Manager programmatically?

Dwaine... and Thx
 
Juct playing around with this and have found a way, I think, that will do it for you.

Dim prc As New Process()
Dim loaded As Boolean
Dim prcid As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If state = False Then
prc = prc.Start("excel.exe")
prcid = prc.Id
state = True
Else
prc.Kill()
state = False
End If

End Sub

This will open and close excel using the one button. You need to store the process id and the process so you can access them from anywhere.

Once you load excel, you will need to keep that process and also get its ID, then on exit of your application, kill the process.

There are probably better ways to do this, but I don't know...first time trying it myself.
 
Oops, In the button click event, I have If state = True and so on, change it to loaded.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top