Hello Everyone,
We have an in-house software that should be looking at the ViewClient_Machine_Name Value in HKEY_CURRENT_USER\Volatile Environment or if we issue a set view command but unfortunately it is pretty much hit and miss. THe application needs to look a the client name that the user is connecting from as this is the only constant that doesn't change
in our Instant Clones deployment
The developer came up with another idea and is able to program the application to look at the System Variable with much more reliability. However, to achieve that they are asking us to deploy a VBS script that should be deployed using Horizon View GPO/Agent Settings and be running at logon (CommandsToRunOnConnect) and reconnect to session (CommandsToRunon Reconnect) with the following command: c:\windows\system32\cscript.exe \\domain.local\netlogon\viewlogin.vbs
Overall the script works when logged in to VM with writable only but as soon as I attach another appstack to it the script breaks and does not run. ALso if I'm fully logged in and go to my Netlogon share and run it then it doesn't work. No errors, nothing in logs, at least I cannot find anything.
Below is the script:
'************************************************************************************************************************
'The following will create applications and printers based on the following variables:
'vMachine = View Client Machine Name
'vIP = View Client IP Address
'vMAC = View Client MAC Address
'This section sets the variables mentioned above based on registry keys set by VMware View Agent
'***********************************************************************************************************************
On Error Resume Next
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", vMachine)
lRC = objRegistry.GetStringValue(HKEY_CURRENT_USER, sPath, "ViewClient_IP_Address", vIP)
lRC = objRegistry.GetStringValue(HKEY_CURRENT_USER, sPath, "ViewClient_MAC_Address", vMAC)
'msgbox "The Remote Device Name is " & vMachine & " @ " & vIP & " (" & vMAC & ") "
Dim WSHShell
Dim Shortcut, Desktop, DesktopPath
Set WSHShell = WScript.CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set fso = CreateObject("Scripting.FileSystemObject")
'Sets ViewClient_Machine_Name as a system variable Dim SysVarReg, Value Set SysVarReg = WScript.CreateObject("WScript.Shell") value = SysVarReg.RegRead("HKCU\Volatile Environment\ViewClient_Machine_Name") SysVarReg.RegWrite "HKCU\Volatile Environment\1\CLIENTNAME", value WshShell.Environment.Item("ViewClient_Machine_Name") = vMachine
We did give Users Modify permissions to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
It seems to be very inconsistent too as it seems to work with some appstacks attached but not all which is majority but it always works fine on Vm with no appstacks and writable only.
I have also attempted to do the same with Powershell Script but that doesn't seem to work at all, not even on appstack free machines.
$userVariables= (Get-ItemProperty -Path 'Registry::HKEY_CURRENT_USER\Volatile Environment')
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name ViewClient_Machine_Name -Value $userVariables.ViewClient_Machine_Name
Also tried UEM Logon task just to see if the PS script would work and even though in logs I see it processed it does not work. When logged in to the machine I can run it just fine. UEM was more for test as it wil lneed to work through Horizon GPO due to reconnect option.
Envronment: AppVoloumes 2.16, Horizon 7.8, vCenter 6.7 U3, Windows 1809 LTSC
Any advise would be very appreciated.