在新过程中开放边缘并再次杀死
我目前正在制作一个程序,该程序本质上需要在Edge中打开一个链接,进行屏幕截图,然后再次关闭浏览器。
第一期:
我可以打开浏览器,但是如果浏览器已经打开,它只是打开一个新的选项卡而不是新窗口。 我不想干扰我们用户可能正在使用的已经存在的开放边缘浏览器,而是打开一个全新的实例,请屏幕截图,然后再次关闭。
我尝试使用以下操作,没有运气 - 它仍然只打开一个新的选项卡
Process proc = new Process();
proc.StartInfo.FileName = "microsoftedge.exe";
proc.StartInfo.Arguments = "http://172.31.44.1/#/cameras" + " --new-window";
proc.Start();
第二期:
尝试使用proc.kill()
i最终杀死该过程时 system.invalidoperationException无法处理请求,因为该过程已退出 ,但是浏览器仍在打开
任何帮助! 先感谢您
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查一下:
使用 System.Diagnostics;
Check this out:
using System.Diagnostics;
似乎Chrome(及其边缘)最近改变了这一行为。
过去,您可以使用参数“ -No-Service-Autorun”来避免关闭原始过程的浏览器,并避免您最终获得无效的(死)过程ID。
这不再起作用。
当在边缘禁用“启动提升”时,第一个窗口确实具有正确的进程ID,但是此后的任何内容仍然无效。
我唯一能找到的有效的方法是使用“ -user-data-dir”参数来提供每个进程的配置文件和过程。
例如,使用“ MSEDGE.EXE -USER-DATA-DATA = C:\ TEST123”(确保每个过程都有一个唯一的目录)。
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).