Jump to content

Recommended Posts

Posted (edited)

Basically this solution works if you every time close the remote session or every time close your application. If not, you will find an unexpected problem. 

EnvGet("CLIENTNAME")

If you disconnect from the session with the program running in the background, the variable CLIENTNAME will be empty for you (not for Windows) the next time you connect. This is because you are getting a new session ID that the application that is constantly running in the background does not know. The solution is to read the client host name not from the environment variable but directly from the registry. Like this:

$reg0 = "HKEY_CURRENT_USER\Volatile Environment"

; we don’t know the session ID, so let’s look at the first (and only) item
$reg1 = RegEnumKey($regFix, 1)

$clientName = RegRead($regFix&"\"&$regVar, "CLIENTNAME")
; of course, all other variables in the session can be queried here

This is a workable solution even if you log in from multiple machines in a row.

Thanks

Edited by Cofee

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...