Kill process started with System.Diagnostic.Process.Start("FileName")

Posted by PedroC88 on Stack Overflow See other posts from Stack Overflow or by PedroC88
Published on 2010-10-02T20:05:30Z Indexed on 2011/01/29 23:26 UTC
Read the original article Hit count: 135

Filed under:
|
|
|

Hello;

I am trying to create an app that will perform actions on specific times (much like the Windows Task Scheduler). I am currently using Process.Start() to lunch the file (or exe) required by the task.

I am initiating a process by calling a file (an .mp3) and the process starts WMP (since it is the default application), so far so good. Now I wan't to kill that process. I know that it is normal behavior for the Process.Start(string, string) to return nothing (null in C#) in this case.

So I am asking how can i close WMP when I called it through Process.Start(string, string)??

Edit:

Please note that I am not opening WMP directly with Process.Start() and this is the line with which I run the process:

VB: Me._procs.Add(Process.Start(Me._procInfo))

C#: this._procs.Add(Process.Start(this._procInfo))

_procInfo is a ProcessStartInfo instance. _procInfo.FileName is "C:\route\myFile.mp3". That is why WMP opens. In any case, all of the Start() methods, except for the instance-one which returns a boolean, return nothing (null in C#), because WMP is not the process that was directly created (please note that WMP is run and the song does play).

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET