Get PID from browser variable

Hello, I have a IE browser variable and there is a situation when I need to kill this browser. I can’t use “Close tab” because in this case UiPath “Can’t communicate with the browser”.

You can try to use a Kill Process action. Illustrated Below:

Yeah, but there are multiple browsers opened and I don’t know which process to kill. All of their process names are “iexplore”. I need to extract some information from browser variable and match it to process information so i could kill it.

You could try to close the tab by using the Ctrl + W hotkey

Or if this tab is alone inside the window you could simply use a Close Application activity, like in the picture below:

HI @Timber,

you can refer this post.

Regards,
Arivu

Sorry for reopening an old post, but I’m having the same problem.
The issues is not “how to close a tab or browser correctly”, but killing a specific instance of a browser.

I have a site where an applet is loading, but sometimes crashes. When the applet crashes, the whole browser (IE) stops responding, and so no normal means of close the browser will work. The only solution is to kill it.
I cannot be sure that there are no other instances of IE running at the same time, and so i need to kill that specific one, and not any other.

Is this possible?
@Timber did you ever find a solution?

Hi @Konrad, did you solve the issue? I have a similar one.

What I brought from my research is that in .Net you can easily get the Id by using

Process.GetCurrentProcess().Id

I got you can do it by invoking code but Im wondering if you found an optimal solution

Hugs!

PD(Sorry to reopen it)

Hello @jmedinacarbonell
No i never found a solution to this problem.
We are currently just crashing every instance by name, and handling the errors that may arise from closing other instances.

The solution you are proposing would give me the ID of UiRobot.exe instead of the ID of the browser, would it not?

Yes it will.

To get the PID list you have to invoke:

Process.GetProcesses

You can also pre-filter the list with a String like “chrome.exe”

Process.GetProcesses(String)

My way to handle the issue with several chrome tabs/instances for example consists by:

  1. Looking which process is added everytime I invoke the app/tab (InitAllApps.xaml/Processes.xaml…)
  2. Storing all of them in an in/out argument present within all framework/process
  3. Then, I have my “custom” PID list ready to point staightly every tab I want to kill.

PD: Here it is the Official Doc

Enjoy your birthday gift! :partying_face:
Hugs

I’ve considered doing the same with the custom PID list, but never got around to do it, as we didn’t get a new process where it was important.
Good to see that it works :slight_smile:
I’m wondering if you ever hit false positives with that solution. For example, what if the machine starts a background anti-virus update? wouldn’t you crash that as well with your solution?

I’m currently using a similar method in my processes where it’s not so important to close the RIGHT instance. Whenever i open an application, i save the applications name to a list, and then cashes the list by name if i need it.
A bit more simple, as long as you don’t have to keep anything open :slight_smile:

Thanks!, but how the??? Does the forum show when you have birthday ? :smiley: