Reputation: 135
I'm currently making a program, that essentially needs to open a link in Edge, take a screenshot and then close the browser again.
1st issue:
I can open the browser just fine, but it just opens a new tab instead of a new window, if the browser's already open. I do not want to interfere with an already existing open Edge browser, that our users may be using, but instead open a completely new instance, take a screenshot and then close it again.
I tried using the following, with no luck - it still just opens a new tab
Process proc = new Process();
proc.StartInfo.FileName = "microsoftedge.exe";
proc.StartInfo.Arguments = "http://172.31.44.1/#/cameras" + " --new-window";
proc.Start();
2nd issue:
When trying to kill the process using proc.Kill()
I end up getting a system.invalidoperationexception cannot process request because the process has exited , but the browser's still open
Any help is appreciated! Thank you in advance
Upvotes: 0
Views: 3597
Reputation: 36
It seems as though Chrome (and therefor also Edge) has changed the behavior of this recently.
It used to be the case that you could use the parameter "--no-service-autorun" to avoid the browser closing the original process, and to avoid you ending up with an invalid (dead) process id. This doesn't work anymore.
When "Startup boost" is disabled in Edge, the first window does have the correct process id, but anything after that is still invalid.
The only thing that I could find that works, is to use "--user-data-dir" parameter to give each process it's own profile and process. For example, use "msedge.exe --user-data-dir=C:\test123" (make sure each process has a unique directory).
Upvotes: 0
Reputation: 1775
Check this out:
using System.Diagnostics;
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe";
proc.StartInfo.Arguments = " --new-window http://google.com";
proc.Start();
Upvotes: 1