I am starting a VLC job to record some streaming audio from within a c# function as follows (the actual args aren’t relevant to the question):
Process proc = new Process();
proc.StartInfo.FileName = "C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe";
proc.StartInfo.Arguments = "someArgs";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
If all works correctly, the Start() function returns immediately and a process is started locally (i.e. VLC).
- How can I get the process ID of this VLC job so I can kill it later? Using proc.Close() closes the process, but does not terminate the VLC job.
- What is the most effective way to kill the VLC job? I have admin privilege locally.
- How can I test that the job did start correctly? Is there some status flag on the proc object I can test?
Thanks
Andrew
The ID should be in your process object as proc.Id.
You can kill it with proc.Kill().
If there is a problem launching the process it will throw an exception (most likely a Win32Exception or an InvalidOperationException; see the help.)