   [.net] VB.NET - Find and kill a process
  I'm making a two part application in VB.NET consisting of a background program and a configuration program. I'm trying to add a section to the config program that detects whether or not the background program is running. If the background program is running the user can close it down, if it is not running then the user can start it running.If Process.GetProcessesByName("reminder") Is Nothing Then    'Reminder isn't running    lblAutoStart.Text = "Reminder is not running."    btnExecution.Text = "Start Reminder"Else    'Reminder is running    lblAutoStart.Text = "Reminder is running"    btnExecution.Text = "Stop Reminder"End IfCurrently this code ends up in "Reminder is running" whether or not the background program is running. I'm assuming that the text passed to Process.GetProcessesByName is the exe name minus the extension? So in this case reminder.exe is the exe name.Any ideas what I've done wrong or how I can do what I'm trying to do?Cheers![Edited by - InsaneBoarder234 on May 27, 2006 7:03:02 AM]
  You are checking whether the array of processes exists; it always does! You should check if the array contains items:If Process.GetProcessesByName("reminder").Lenght = 0 Then    'Reminder isn't running    lblAutoStart.Text = "Reminder is not running."    btnExecution.Text = "Start Reminder"Else    'Reminder is running    lblAutoStart.Text = "Reminder is running"    btnExecution.Text = "Stop Reminder"End IfEdit: Read this