I have a scenario where I have to check whether user has already opened Microsoft Word. If he has, then I have to kill the winword.exe process and continue to execute my code.
Does any one have any straight-forward code for killing a process using vb.net or c#?
You’ll want to use the System.Diagnostics.Process.Kill method. You can obtain the process you want using System.Diagnostics.Proccess.GetProcessesByName.
Examples have already been posted here, but I found that the non-.exe version worked better, so something like:
You probably don’t have to deal with
NotSupportedException, which suggests that the process is remote.