Scripts for fast address book updating in Lync 2010/2013

As you know, Lync have its own address book (AB) that downloaded by clients. By default, the download and update process of address boook in Lync 2010/2013 triggered in first 60 minutes (random time) after program start. In our company this situation was considered as wrong, thus I had to find solution how to ensure guaranteed updating of Lync address book right after the client starts. Also, there are other issues with delta-updating of address book, like a big delays (5-10 days) after changes in Active Directory are repliacted to Lync AB. 

The consequences of such behavior:

  • Incomplete information in the contact cards (irrelevant titles, incorrect phone numbers, no phones, etc.).
  • The impossibility of finding the right employee.

These problems are solved by forced updating of Lync address book to client computers. The technique is as follows:

  1. Stop Lync.
  2. Delete Lync user profile from Windows user profile.
    Is there:
    Lync 2013 - c:\Users\user\AppData\Local\Microsoft\Office\15.0\Lync\
    Lync 2010 - c:\Users\user\AppData\Local\Microsoft\Communicator\
    You can delete the whole folder - it will re-downloaded again.
  3. Start Lync.
  4. Wait until address book are downloaded.

By default p.4 performed during one hour after Lync started. To avoid this and update AB directly after Lync started, do the following:

Lync 2013 - reg add HKLM\Software\Policies\Microsoft\Office\15.0\Lync /v GalDownloadInitialDelay /t REG_DWORD /d 0 /f
Lync 2010 - reg add HKLM\Software\Policies\Microsoft\Communicator /v GalDownloadInitialDelay /t REG_DWORD /d 0 /f

Automation update Lync address book

We have automated the update process of address book on the clients using set of scripts. These scripts are run when the user logs on to the computer during processing Group Policies.

Lync-2010-cache.vbs - clearing Lync-profile in Lync 2010
Lync-2013-cache.vbs - clearing Lync-profile in Lync 2013
lync-ab-settings.bat - update registry for fast AB updating

The contents of scripts I will show below, and now as the scripts specified in group policy:

Computer Configuration -> Policies -> Windows Settings -> Scripts -> Startup:

\\domain.local\NETLOGON\Lync\lync-ab-settings.bat

User Configuration -> Policies -> Windows Settings -> Scripts -> Logon:
cscript \\domain.local\NETLOGON\Lync\Lync-2010-cache.vbs
cscript \\domain.local\NETLOGON\Lync\Lync-2013-cache.vbs

Scripts for fast address book updating in Lync 2010/2013

The contents of the scripts

Lync-ab-settings.bat

reg add HKLM\Software\Policies\Microsoft\Office\15.0\Lync /v GalDownloadInitialDelay /t REG_DWORD /d 0 /f
reg add HKLM\Software\Policies\Microsoft\Communicator /v GalDownloadInitialDelay /t REG_DWORD /d 0 /f

Lync-2010-cache.vbs

Option Explicit
Dim objShell12
Dim objUserEnv
Dim strUserPro
Dim userProfile,SipProfile
Dim proPath
Dim objFSO
Dim objStartFolder
Dim objFolder
Dim colFiles
Dim objFile
Dim Subfolder
Dim uProfile

Set objShell12=CreateObject("WScript.Shell")
Set objUserEnv=objShell12.Environment("User")
userProfile = objShell12.ExpandEnvironmentStrings("%userprofile%")

'Delete sip Profile
SipProfile=userProfile & "\Local Settings\Application Data\Microsoft\Communicator"
uProfile=userProfile & "\Local Settings\Application Data\Microsoft"

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = uProfile
Set objFolder = objFSO.GetFolder(objStartFolder)

ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
      proPath = Right(Subfolder.Path,4)
    If proPath = "Lync" Then
		DeleteSip SipProfile
	End if
    Next
End Sub

DeleteSip SipProfile
SipProfile=SipProfile & "\sip_*"
DeleteSip SipProfile
WScript.Quit

Sub DeleteSip (strSipPath)

On Error Resume Next
Dim objFSO
Dim objFolder,objDir
Dim i
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder(strSipPath)

'delete folder
For i=0 To 10
	For Each objDir In objFolder.SubFolders
	objDir.Delete True
	Next
Next

'clear all objects
Set objFSO=Nothing
Set objFolder=Nothing
Set objDir=Nothing

End Sub

Lync-2013-cache.vbs

Option Explicit
Dim objShell12
Dim objUserEnv
Dim strUserPro
Dim userProfile,SipProfile
Dim proPath
Dim objFSO
Dim objStartFolder
Dim objFolder
Dim colFiles
Dim objFile
Dim Subfolder
Dim uProfile

Set objShell12=CreateObject("WScript.Shell")
Set objUserEnv=objShell12.Environment("User")
userProfile = objShell12.ExpandEnvironmentStrings("%userprofile%")

'Delete sip Profile
SipProfile=userProfile & "\AppData\Local\Microsoft\Office\15.0\Lync"
uProfile=userProfile & "\AppData\Local\Microsoft\Office\15.0"

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = uProfile
Set objFolder = objFSO.GetFolder(objStartFolder)
ShowSubfolders objFSO.GetFolder(objStartFolder)

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
		proPath = Right(Subfolder.Path,4)
		If proPath = "Lync" Then
			DeleteSip SipProfile
		End if
    Next
End Sub

DeleteSip SipProfile
SipProfile=SipProfile & "\Sip_*"
DeleteSip SipProfile
WScript.Quit

Sub DeleteSip (strSipPath)
On Error Resume Next
Dim objFSO
Dim objFolder,objDir
Dim i
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder(strSipPath)

For i=0 To 10
	For Each objDir In objFolder.SubFolders
	objDir.Delete True
	Next
Next

'clear all objects
Set objFSO=Nothing
Set objFolder=Nothing
Set objDir=Nothing

End Sub

Tags: script, lync (en), lync 2013 (en), lync 2010 (en)

PrintEmail

Add comment


Security code
Refresh