Gaining control over process started by an URI in C#
-
28-10-2019 - |
Question
I'm making a program which opens a configured application after with the passed paramters through an url with shell execute. I achieved this with the following:
ProcessStartInfo procinfo = new ProcessStartInfo(URI);
procinfo.UseShellExecute = true;
Process App = Process.Start(procinfo);
I want to kill this process later after some minutes through this project that I could do by App.Kill() but the problem is that the Process.Start() always returns null if I pass the URI. How could I reach that process?
Solution
If the address of the executable file to start is a URL, the process is not started and null is returned. http://msdn.microsoft.com/en-us/library/53ezey2s.aspx
Even if you specify a browser, the process could be a simple handler that sends a message to an existing process (or opens another process) and closes itself immediately.
But you may explicitly launch the browser you want if you know how its process works.
Process p = Process.Start(browserExePath, url);