VBScript ; Set UserPreferencesMask Binary Registry Key

Set UserPreferencesMask Binary Registry Key


An ideal solution for configuring display options for ‘best performance’ on Citrix and Terminal Servers:



Simply add the following code to an existing VB logon script or create a new one to run along side you exusting scrip:

Const HKEY_CLASSES_ROOT  = &H80000000
Const HKEY_CURRENT_USER  = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS         = &H80000003

Set WshShell = CreateObject(“WScript.Shell”)

‘Lookup User Account Name and Logon Domain Name
Set objNetwork = CreateObject(“Wscript.Network”)
currentDomain = objNetwork.UserDomain
currentUser = objNetwork.UserName

Set wmiLocator = CreateObject(“WbemScripting.SWbemLocator”) ‘ Object used to get StdRegProv Namespace
Set wmiNameSpace = wmiLocator.ConnectServer(objNetwork.ComputerName, “root\default”) ‘ Registry Provider (StdRegProv) lives in root\default namespace.
Set objRegistry = wmiNameSpace.Get(“StdRegProv”)

uBinary = Array(&H90,&H12,&H01,&H80)
cmd = objRegistry.SetBinaryValue(HKEY_CURRENT_USER, “Control Panel\Desktop”, “UserPreferencesMask”, uBinary) 

The changes will be applied at second logon (ie first logon the change is written to the users hive, at second logon this setting will be used)