View Single Post
  #8 (permalink)  
Old 12-29-2008, 10:51 AM
JohnH's Avatar
JohnH JohnH is offline
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,325
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Friendly names doesn't contain file extensions. I would rather use a For-Each loop:
Code:
For Each p As Process In Process.GetProcessesByName("notepad")
    Try
        If p.CloseMainWindow() Then
            MessageBox.Show("nice process close")
        Else
            p.Kill()
            MessageBox.Show("oops, had to kill it :(")
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try            
Next
Remember to use Code blocks when posting code, it makes the post readable. It is just one click of the Code button in message editor.
__________________
Reply With Quote