Environment Variable CLIENTNAME not visible by the Robot

Hi all,
when running the process by de Robot, in a Windows Server 2016, it can’t access the Environment Variable CLIENTNAME.

System.Environment.GetEnvironmentVariable(“CLIENTNAME”)

the extrage thing is that I’m running a CMD with the SET command, and I can see the variable.
But the robot cannot see it.
I also tried to see all the variables with a loop over the System.Environment.GetEnvironmentVariables, and there are some others variables that I can not se besides the CLIENTNAME, like the SESSIONNAME.
But I can see them with the SET command in CMD.

Any ideas?

1 Like

Hi @marcelo_bulant,
Welcome to the Community!
It might be related to fact that windows is applying some variables differently to some processes. Here’s is quite old document about it:
https://support.microsoft.com/en-us/topic/clientname-and-sessionname-enviroment-variable-may-be-missing-5afa6784-fde1-5a20-4585-43acd2e0673b

You may try to use powershell method to get this to work.

Hi,
We’ve already check that old article from MS. And no, this is not the situation.

We’ve already tried access the variable by:

  1. CMD command “SET”
  2. Powershell command “Get-ChildItem Env:CLIENTNAME”
  3. UiPath Activity “GetEnvironmentVariable”
  4. .Net code “Environment.GetEnvironmentVariable(“CLIENTENAME”)”

All of the above works perfectly manually, one of the above works.

The problem is as follows:
The Service Mode Robot Service (SCM-managed)** (UiPath.Service.Host.exe), Runs under the Local System.

Hence, the Local System cannot access directly to the Environmetn Variable CLIENTNAME.
Because this variable is saved in the Registry under the User’s Volatile Environment variables.

In orther for us the get the value of a User Env. Variable, we need to Query de registry either by powershell or cmd script, and get the value.

1 Like

Indeed. It’s exactly what I wrote :slight_smile:

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