Personalize Users Microsoft office

By | April 12, 2013

Having problems when users try to open a office document that is already open by another user but it doesn’t show the username.  The problem usually resides around a missing registry key at

HKCUSoftwareMicrosoftOfficeCommonUserInfo

run the following VBS script as a logon script to set the registry key correctly.

on error Resume Next
const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_ 
strComputer & "rootdefault:StdRegProv")
Set objNetwork = WScript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName
Dim objADSysInfo : Set objADSysInfo = CreateObject("ADSystemInfo") 
Dim objUser : Set objUser = GetObject("LDAP://" & objADSysInfo.UserName) 
strFNLN = objUser.FirstName & " " & objUser.LastName
strInitials = Left(objUser.FirstName,1) & Left(objUser.LastName,1)
strKeyPath = "SoftwareMicrosoftOfficeCommonUserInfo"
strValueName = "UserName"
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strFNLN
strValueName = "UserInitials"
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strInitials
strValueName = "Company"
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,"Company Name"
strKeyPath = "SoftwareMicrosoftOfficeCommon"
strValueName = "Username"
oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strUserName
WScript.quit