Using Environ to get Terminal Service ClientName and SessionName (1 Viewer)

Rx_

Nothing In Moderation
Local time
Today, 10:07
Joined
Oct 22, 2009
Messages
2,803
Was trying to solve another problem, came across this. Thought it might come in handy for Terminal Services or Citrix.
Has anyone tried this? Please indicate OS for both client and server.
Using Environ to get the Terminal Services ClientName

Returns value of ComputerName environment variable of a remote host. The ClientName environment variable is Terminal Services specific, and only appears in a user's environment when they are logged on to a Terminal server, in Remote Administration or Application Server mode.
Environ("ClientName")
example result:MyServerUsing Environ to get Terminal Services SessionName

The SessionName variable is only defined if the Terminal Services system component is installed to the Windows XP clients or newer. [1] When a client connects via a terminal server session, SessionName environment variable is a combination of the connection name, followed by a pound symbol {#} and then the session number.
Environ("SESSIONNAME")
example result: Console
 

Rx_

Nothing In Moderation
Local time
Today, 10:07
Joined
Oct 22, 2009
Messages
2,803
I was off with the Environ, it is the WMI calls that do this.
How soon I forget.
http://msdn.microsoft.com/en-us/library/aa394599(v=vs.85).aspx

One of my post uses this to boost the Priority Thread on Access.
http://www.access-programmers.co.uk/forums/showthread.php?t=235076&highlight=Priority

(Attachment) Uploaded an Excel file with macros that use the WMI calls.
Use the list box to call a different WMI function, see the results in Excel.
This will expose more than anyone wants to know about the OS.

The VBA in this Excel attachment can be exposed and used in MS Access.
 

Attachments

  • WMI Query.zip
    163.6 KB · Views: 459

Users who are viewing this thread

Top Bottom