Good day to all. Task: I start the process (chrome browser with the given url), after several operations I need to close the same page. I run using

var proc = Process.Start(..); 

and finish with, proc.Kill(); it works tolerably in all browsers, in chrome it throws an error that such a process does not exist. How to be? Thank you all in advance.

PS js not to offer, since it is necessary to close the page natively. Also opening the task manager, I found out that chrome spawns its processes, separately the plugins are separate pages, it turns out I need to somehow catch my page and correctly complete it.

    2 answers 2

    Yes, you yourself almost answered your question - you can check the PID of the process you need in the tab Viev Background Pages -> rbt-click -> Process PID to put a tick. The only thing, when I tried to kill the process through the terminal, then “Dead Jim” appeared on the page, I assume that I need to kill other processes as well. In general, look in this direction.

    • Well, this option is rude, somewhere on the steckoverflow the person wrote that you can run chrome from the url, and put the key in the title with it, then when everything was done, find a page on this key and kill the process, now I just can’t find this post, and I can not find a similar one. - AndereyMaybe

    The problem with chrome is that it actively creates and deletes child processes, and if you run chrome when it is already running, it will cling to the existing one, and this process will disappear.

    Solution options:

    1. Kill all chrome processes by name
    2. Run chrome with the --user-data-dir= parameter, which will create a separate profile for chrome and will ensure that it does not attach to the existing one. Close chrome through proc.CloseMainWindow() (it will allow him to finish off his children guaranteed).