|
-
Jul 18th, 2004, 02:42 AM
#1
Thread Starter
Fanatic Member
Detect running process and shut it down
Hey,
I was kind of surprised to find no results to my question on a search in VB.NET - very surprising to see no one has wanted this, or was i just searching wrong?
Well, my problem is this. I have a program that renames an exe, but of course if the exe is open it wont work.
So i need some code to detect whether the exe is running, and if it is, shut it down so that i can rename it.
This is a really important aspect to my program as it is very likely that the exe is open at the time.
Thanks very much, I'm sure i wrote something like this in vb6. I'll try to see if i still have it.
-
Jul 18th, 2004, 03:28 AM
#2
Sleep mode
You can query a process by it's name . Here I'm shutting down an application named "matrix" .
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
Dim p As Process
For Each p In Process.GetProcesses
Me.ListBox1.Items.Add(p.ProcessName)
If p.ProcessName = "matrix" Then
p.Kill()
If p.HasExited Then
MessageBox.Show("Process was terminated successfully")
End If
End If
Next
End Sub
-
Jul 19th, 2004, 03:45 PM
#3
Thread Starter
Fanatic Member
thanks very much.
that looks way easier than what i thought it would! I was expecting some complex api calls.
i'll try it later, i'm very depressed at the moment tho.
thanks again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|