One of the challenges I have been dealing with recently specifically in educational establishments is how can we get location based scripts to work inside a View desktop. A number of these types of establishments already have complex login scripts to map printers, shares etc based upon the location of the desktop you are logging into. View adds a layer of complexity to these components especially one you want one desktop, e.g. staff and students. In the physical world the login scripts will look at the name of the desktops and map the resources / make the changes as required. We obviously can’t do this easily in the virtual world with a signal desktop model.
Now there are ways around this such as the ThinPrint location based printing and third party software such as RES or AppSense for persona management. But that doesn’t stop us wanting to create customised solutions based around each customers individual requirements or trying to safe some money when we already have sufficient profile redirection etc in place.
The good news with a bit of playing it is still possible, when you log into a View Desktop the View Agent populates a number of registry entries with some key information, for example see the screenshot below.
These registry settings are held in HKEY_CURRENT_USER>VOLATILE ENVIROMENT and they all will start with ViewClient, from this information we can see the IP address I am connecting from, the broker URL, the username for which I am logged into my client with, the name of the client and the type of client that I am using. So straight away from the above information we can see that I am connecting in from my Mac, from an external IP.
The next stage is to harness this information to create some location based scripts. I have only just started playing with this but there are a number of ways to do this, at the moment I am concentrating on VBS scripts as a number of customers are already utilising VBS. We could easily use Powershell to query this information but that wouldn’t be ideal for a login script situation.
Now I will start this with a caveat, I am by no means a VBS expert and the code below is something I have hacked together for an example.
This script looks in the registry for the ViewClient_MachineName registry key and displays the contents of the machine you are connecting from on the View Desktop
Option ExplicitDim WshShell, ClientName, objFSO
Set WshShell = WScript.CreateObject(“WScript.Shell”)Set objFSO = CreateObject(“Scripting.FileSystemObject”)
ClientName = WshShell.RegRead(“HKCU\Volatile Environment\ViewClient_Machine_Name”)MsgBox ClientName
When the user connects in with the script above running as a logon script they get the following message on the screen
Now by itself that is little use, but could easily be expanded to look if the IP is internal or external and display a company policy message or support message for external users.
With the script below I have expanded it to detect if the user is connecting from a client (Thin Client or PC) in the art department of the science department, it will then map the correct R: drive resource share for the specific department.
Dim WshShell, ClientName, objFSO, objNetwork
On Error Resume Next
Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objNetwork = CreateObject(“WScript.Network”)
‘Set the Clientname variable to look at the view registry entry
ClientName = WshShell.RegRead(“HKCU\Volatile Environment\ViewClient_Machine_Name”)
‘Disconnect the mapped drive if it exists to stop problems later
objNetwork.RemoveNetworkDrive “R:”, True, True
‘Map the Art drive if the client name contains art
If Instr(1, ClientName, “art”) > 0 Then
objNetwork.MapNetworkDrive “R:” , “\\file1\cwptemp\Art”
‘Map the Science drive if the client name contains Science
If Instr(1, ClientName, “science”) > 0 Then
objNetwork.MapNetworkDrive “R:” , “\\file1\cwptemp\Science”
The possibilities are endless with this and really comes down to your imagination for what you could create to customise a users environment based upon those parameters. One other possibility with this would be to start collecting the client type information so you can start to understand what end devices your users are connecting from. This would help significantly when it comes down to support and updates.
I would really like to hear from people that are using scripts like this or are intending to after reading this and how you intend to be using it.
I will update my blog with more use cases when I can.