Get Process Name

Hi,
I need to get the name of the process:
image

Used this: Process.GetCurrentProcess.MainWindowTitle

And it worked fine. but in some process I got an error. I solved this error by adding System.Diagnostics. Unfortunately, it does not display any name now. Anyone know how to solve this problem?

HI @Paulina_x

Check out this XAML file

GetProcessName.xaml (6.8 KB)

image

Regards
Gokul

I can’t use “environment.CurrentDirectory” because “get process name” I want to use in the library. Sorry. I forgot mention that.

Hi @Paulina_x

Check out this thread

Regards
Gokul

This doesn’t get the process name. It gets the main window title of the running job, so if you have a mainframe connection - for example - you’ll get the name of the mainframe window.

Hi @Paulina_x, @Gokul001 and @postwick

There is now a standard activity/object in Studio/robot which can get you the process name during runtime.

Get Current Job Info activity returns a Object containing runtime related properties.

image

In your case, you are looking for ProcessName. JobInfo.ProcessName will get you what you want.

The process name in this case was "ModernClassicDemos"
image

We have used this across our automations, not failed us ever! We use it to get the current workflow name where the robot is executing.

Here is the sample file:
GetProcessName.xaml (4.9 KB)

Hope this helps!

4 Likes