VMWare View machine does not supply machine name correctly in AppSense Environment Manager logon trigger

By James Rankin | 18th April 2012

One of my former colleagues emailed me regarding this issue that he had experienced with a VMWare View 4 virtual Windows 7 desktop. During the logon trigger, various actions he had set dependent on the client machine name were not functioning correctly. After investigation, it appeared that for some reason the VMWare View client could not supply the machine name correctly.

This appeared to be fairly difficult to rectify at first glance as we would have to pull the machine name from the Registry and then set it as a variable. Normally when needing to return the machine name, the first thing we think of is the %computername% variable, which appeared to be where the error was occurring. Luckily for my colleague (or luckily for me, because I would have been the one he contacted to work out a way around this!) this issue was already known to AppSense support and they already have a workaround available.

First, create a node for the issue and create a Custom scripted action – Action | Custom & Execute | Custom Action

Then insert this VB script into the Custom Action field

‘ get Clientname

Const HKEY_CURRENT_USER = &H80000001

Set wmiLocator=CreateObject(“WbemScripting.SWbemLocator”)
Set wmiNameSpace = wmiLocator.ConnectServer(“.”, “root\default”)
Set objRegistry = wmiNameSpace.Get(“StdRegProv”)
sPath = “Volatile Environment”

lRC = objRegistry.GetStringValue(HKEY_CURRENT_USER, sPath, “ViewClient_Machine_Name”,sComputerName) ‘Query Registry for client name

‘set the environment variable

Set oShell = CreateObject(“WScript.Shell”)
Set oUserEnv = oshell.Environment(“USER”)
oUserEnv(“ConnectingPC”) = sComputerName

Then create a child action using Action | Environment | Set Environment Variable, and set the variable as shown in the screenshot below

Once you’ve done this, you should now be able to use the Environment Variable you’ve just created as a filter for machine name instead of the traditional Condition | Computer | Computer Name method. You’ll need to use Condition | Environment | Environment Variable and set the parameters to whatever you require.

Update – I was asked by Aaron Parker why the variable appears to be set first by the script, and then again by the Environment Variable action. This is an AppSense-recommended fix, so I put the question to them, and didn’t receive an answer (unsurprisingly). I can speculate that it may be to do with the way environment variable refreshes behave. If you need a node to use an Environment Variable action, after version 8.1 you put it into the Trigger Environment section so that it is certain to be correctly defined prior to whatever conditions depend on it. I can only assume, without any clarification forthcoming from AppSense, that this refresh issue is the reason the variable is set once by a script and then again by the Action. I am happy to be corrected however.

Back to Blogs

Get in touch

Please call us on 0191 481 3446 or email and we’ll get back to you.

Chat to our team Messenger