Retrieve Name of Robot Executing Process

Hi all, I’ve seen this question asked a couple of times on the forum, but it doesn’t look like it’s ever been answered fully/sufficiently (see Get Machine Name or Name of Robot in Orchestrator, Get the robot name in the code of the robot).

I know how to get Machine Name (Environment.MachineName) and Username (Environment.Username) using Environment variables, but what I would really like to know is how to retrieve the name of the robot that is executing a process as it is defined in Orchestrator.

For example, say I have a process named “Compile Report,” and I have four robots defined in Orchestrator: Dev John Doe, Dev Jane Doe, Prod John Doe, Prod Jane Doe (for simplicity, let’s assume all robots are assigned to the same environment). If I execute the process and allocate dynamically to 1 robot, I would like to be able to retrieve the robot name during execution.

My intent is to use the robot name as part of the filepath for a custom log file. We may end up running multiple instances of the robot simultaneously, so I am trying to build with “parallelization” in mind. If the log filepath includes the robot name and a timestamp, it should be unique no matter how many robots execute the process simultaneously. Of course, there are other ways to obtain a unique identifier, like using Environment.MachineName + Environment.UserName in place of robot name, but retrieving the robot name seems like it should be so simple. My curiosity won’t let me let the question lay any longer.

Thanks in advance!

Hi @SpencerAF - Need to explore if there is any other easy way but for now I can think of fetching the robot details using robot API by filtering on machine name and username.

odata/Robots?$filter=MachineName%20eq%20’youmachinename’%20and%20Username%20eq%20’yourUserName

2 Likes

try this

Process.GetCurrentProcess.MainWindowTitle)

2 Likes

Thank you Mahesh, I appreciate your quick reply! For the time being, I may continue concatenating machine name and username, especially since I think it will be more readable to our newer developers. But if a simpler way doesn’t currently exist to access the robot name, I think that could be a handy (and hopefully easy-to-implement) feature for a future version!

Thanks Muralidhar, but that actually retrieves the name of the process/project, not the name of the robot executing the process. I’m also not sure what the result would be running the robot from Orchestrator since the Studio window with the name of the project would not exist.

I haven’t solved this in what I’d say is a perfect way, but the way we do it is to have a asset, RobotName, on orchestrator, and it’s set per robot to be the name of the bot.

So when a bot gets that asset, it gets its name.

1 Like

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