How to check if a process exist?

Hi UiPath,

How can I check if outlook is already running?

I want to use if conditional statement prior outlook operation to avoid bug. I want to avoid using the delay activity.

thanks!

1 Like

instead of you checking always , if its blocker for your process just kill every time before process in init only

Hi @alvin.c.apostol26,

You can check whether Outlook is opened by using the Get Process activity.

Or you can check with element exist activity.

Regards,
MY

1 Like

@alvin.c.apostol26
see this answer

basically you can put this in if activity

System.Diagnostics.Process.GetProcesses.AsEnumerable().Any(Function (prcRunning) prcRunning.ProcessName.ToLower.Trim.Equals("OUTLOOK".ToLower.Trim))

if its true, then outlook is running, otherwise its not running

5 Likes

But killing a process terminates it ‘unnaturally’ and gives artifacts like “browser was closed, do you want to restore it to former state”-ish message that then needs to be handled by a UiPath flow. what other way to close the app? Shortcut ALT+F4? Click the X?

i’ve made a workflow like this in my projects. :slight_smile:

in_process is argument with process name.
Process.GetProcessesByName(in_process).any

1 Like
  1. use close application,
  2. make a workflow to click “X” in the browser window
    etc

unless you explicitly set browser to open blank tab every time browser is opened, it will open the other tabs as well, so to be safe you can also make a UiPath workflow that recursively closes every tab in the browser until there are no more tabs

1 Like

Any idea why ‘msedge’ processes is reported but no browser is present? Is the browser process called anything more than ‘msedge’ and are there other background processes of Edge laying around that also are named ‘msedge’?

other question; trying to shut down Excel but it doesn’t seem to respond to ‘msexcel’, where do I find the right process name?

Using this:
System.Diagnostics.Process.GetProcesses.AsEnumerable().Any(Function (prcRunning) prcRunning.ProcessName.ToLower.Trim.Equals(“msedge”.ToLower.Trim))

Thank you for your help! :slight_smile:

Yea ur code looks fine, it’s clear and easy to understand.

for excel is just “excel” :slight_smile:
u can click the details tab in task manager and it will show the process by name

1 Like

What do you have in your workflow as Catch and/or Finally?