KillAllProcesses give me an exception

This is my code. Uipath kills the processes but throws an exception.
I am passing processes EXCEL,iexplore,OUTLOOK

In kill process activity I pass process.ProcessName as ProcessName

Error

Please give suggestions to fix it.
This code sometimes works very fine and sometimes does not.

I think the issue is with Get Processes. It shows me Outllok in the current running processes which it is not there.

1 Like

Did you try to kill the process directly,what i mean is use the kill process activity and pass the processname. @Chand

cheers

3 Likes

@Chand

Print the processes name inside the loop and before passing to Kill Process activity and check whether it’s passing process name correctly or not.

@Chand

May I know what exactly you are killing for each loop.

sometimes while fetching the processes list an application contains multiple instances.

when you kill process it will kill all instances, sometimes we will get error when you trying to kill which is already killed previously.

Ex: I have 2 instance of chrome and we are killing all the process in a loop , at first we killed chrome and in the next loop the chrome is not exists and we try to kill it again which encounters error.

2 Likes

Hi , inside for each loop
For kill process activity property ‘process’ give value as ‘Item’
Instead of using value at process name property

And it is always recommended to put kill process inside try catch

1 Like

Hi @Sreelatha278

Trying to kill a process will get a error because of many reasons.
but most of time, whether the kill activity is success or failure, the target process is already killed.
So, just need to set ContinueOnError to True that can avoid an exception be thrown.
Or also you can try to catch that exception and just make some memo in your log without throwing.

1 Like

yes n that works fine. but I want to kill multiple processes and I have stored them in config file

1 Like

ok. That is possible.But in my config file, I have kept only one instance.

1 Like

Here you go a document from uipath in using Get Process activity

This would give you an idea on this
Cheers @Chand

1 Like

Ok great @Chand

Can you share what processname did you get the error?

cheers

2 Likes

It didnt help me

1 Like

Kindly have a view on this
Hope this could surely resolve your issue

Cheers @Chand

1 Like

Hi @Chand You’ve mentioned that “In kill process activity I pass process.ProcessName as ProcessName”. Correct me if I am wrong, may I know why you are passing process.ProcessName, where should only pass process name.

1 Like

because i am running in a loop.

I have 2 loops. let me share my code.

@Chand
we encountered similar issues and after an RnD we worked out apattern close to your scenario:

Set up a String List with the process names that get to kill. This can be done also with values from the config

grafik
here we go with OUTLOOK, EXCEL, iexplore

then try to retrieve for each process name the process as long all are killed:

for each is iterating over process name to kill list
while is killing the particular process so often till no one longer is existing

We did in this way as we learned that process / childprocess structures confused iteration over process lists. Does mean: A process kill can also kill multiple processes when it come from childprocess relationships. But with this logic we didnt longer mind (Strategy - Kill to end)
grafik

Find the XAML here: KillProcesses.xaml (7.5 KB)

Let us know your feedback and flag the solving post as solution. So others can benefit from it.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.