Often times we here at VMware get asked, “How do I determine the connecting client system info?“. Many times this is asked in conjunction with ThinApp as well. Therefore, I figured I’d post this script here to assist anyone looking for this information – at least in conjunction with ThinApp. ☺
This VBScript sample code (Thanks to Todd Dayton – one of our Desktop Specialists – for providing the meat of the code) will look up and report on the View Client Machine Name (the client computer), the View Client IP Address, and the View Client Mac Address. According to Todd, reading the registry of the virtual desktop directly is the best way to ensure these values are properly obtained.
In the below script I have the data lookup defined in two different ways – one via an NTDLL call (the first part) and the other being a Win32 call (the second part) as often times customers desire to have validation logic such as this embedded into a ThinApp package so the ThinApp packaged app will operate in a certain fashion based upon the scripted outcome of the validation logic. And often times, customers wish to use the View Client info to determine all of this.
The issue with doing an NTDLL registry call via a VBScript within a ThinApp package is, ThinApp doesn’t fully support NTDLL registry calls. At least, not properly (yet) – and so one will get various anonymous outcomes when using NTDLL registry calls like the one shown in the scripted example. Therefore, I’ve provided the below script which shows both ways to gather the View Client info – via an NTDLL registry call and via a Win32 registry call.
As a simple test, drop this code into a ThinApp package, rebuild and execute. From within a ThinApp package, it is very likely you will not get any or all values properly returned in the MSGBOX output for the NTDLL call, but you will get them via the Win32 call – or at least, what they are currently set to within the registry of the View session (NOTE: If the values are not updated, it’s not a script issue at that point).
Sample Code:
'============================================================================================== 'Notes: '====== 'Windows Registry calls can be made at two levels within the Windows operating system. One is 'the Win32 level and the other is at the NTDLL level. ' 'Unfortunately, ThinApp currently only hooks the Win32 level, so registry calls such as '"WMI stuff(objRegistry)" which make calls at the NTDLL level will not be correctly handled by 'ThinApp ' '============================================================================================== '============================================================================================== 'NTDLL Call to View Session Details '============================================================================================== 'Declare Environment Variables Dim vMachine, vIP, vMAC 'Set Environment Variables Const HKEY_CURRENT_USER = &H80000001 Set wmiLocator=CreateObject("WbemScripting.SWbemLocator") Set wmiNameSpace = wmiLocator.ConnectServer(".", "root\default") Set objRegistry = wmiNameSpace.Get("StdRegProv") sPath = "Volatile Environment" 'Lookup values in registry and assign to variables lRC = objRegistry.GetStringValue(HKEY_CURRENT_USER, sPath, "ViewClient_Machine_Name", vMachine) lRC = objRegistry.GetStringValue(HKEY_CURRENT_USER, sPath, "ViewClient_IP_Address", vIP) lRC = objRegistry.GetStringValue(HKEY_CURRENT_USER, sPath, "ViewClient_MAC_Address", vMAC) 'Test Message Box to show values MsgBox "The Remote Device Name is " & vMachine & " @ " & vIP & "(" & vMAC & ")",, "NTDLL Call Test" '============================================================================================== 'Win32 Call to View Session Details '============================================================================================== 'Declare Environment Variables Dim vMachine, vIP, vMAC 'Set Environment Variables Set WSHShell = CreateObject("WScript.Shell") 'Lookup values in registry and assign to variables vMachine = WSHShell.RegRead("HKEY_CURRENT_USER\Volatile Environment\ViewClient_Machine_Name") vIP = WSHShell.RegRead("HKEY_CURRENT_USER\Volatile Environment\ViewClient_IP_Address") vMAC = WSHShell.RegRead("HKEY_CURRENT_USER\Volatile Environment\ViewClient_MAC_Address") 'Test Message Box to show values MsgBox "The Remote Device Name is " & vMachine & " @ " & vIP & "(" & vMAC & ")",, "Win32 Call Test"
Feel free to download the View Client Machine Name.zip and give it a go.
Hope this helps clarify a few things when you or your customers are building ThinApp packages relying upon the View Client info.
