So... If anyone needs it, i found solution:
1) Make a network share on your server and make sure all client PCs have R\W access to it;
2) Copy your phonebook.csv file to network share with names for each client - client1.csv, client2.csv, client3,csv etc.;
3) On each PC make a symlink to phonebook.csv file in network folder -DELETE file phonebook.txt in your program or AppData folder, then open CMD and execute a command - mklink /H "c:\PhonerLite\phonebook.csv" "\\SERVER\RealPhonebook\client1.csv" (replace paths with correct for your case);
4) Make sure your client reads phonebook file correctly;
5) Create on server in folder, where your phonebooks are stored batch and vbs files for merge, deduplicate merged results and make all phonebooks equal:
sync.bat: (merges all files)
@echo off
type nul > temp.csv
type nul > sync.csv,
copy *.csv temp.csv
for /f "delims=" %%I in (temp.csv) do findstr /X /C:"%%I" sync.csv >NUL ||(echo;%%I)>>sync.csv
del temp.csv
exit
cleanfile.vbs (Removes SUB simbol at the end of merged file, i am ukrainian, maybe it appears because of ukrainian names in phonebook)
Dim objFS, objFile, strPath, arrTemp
strPath = "sync.csv"
Set objFS = CreateObject("Scripting.FileSystemObject")
If objFS.FileExists(strPath) Then
Set objFile = objFS.OpenTextFile(strPath, 1)
arrTemp = Split(objFile.ReadAll, vbNewLine)
objFile.Close
For i = 0 To UBound(arrTemp)
If InStr(1, arrTemp(i), "
", vbTextCompare) > 0 Then arrTemp(i) = Replace(arrTemp(i), "
", "")
Next
Set objFile = objFS.CreateTextFile(strPath, True)
objFile.Write Join(arrTemp, vbNewLine)
objFile.Close
Set objFile = Nothing
End If
Set objFS = Nothing
WScript.Quit 0
deduplicate.bat (removes duplicate lines from merged file)
@echo off
setlocal disableDelayedExpansion
set "file=sync.csv"
set "line=%file%.line"
set "deduped=result.csv"
:
efine a variable containing a linefeed character
set LF=^
::The 2 blank lines above are critical, do not remove
>"%deduped%" (
for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("sync.csv") do (
set "ln=%%A"
setlocal enableDelayedExpansion
>"%line%" (echo !ln:\=\\!)
>nul findstr /xlg:"%line%" "%deduped%" || (echo !ln!)
endlocal
)
)
>nul move /y "%deduped%" "ready.csv"
2>nul del "%line%"
exit
clean.bat (removes temp files and replaces all your phonebooks witn deduplicated merged file, i made also a backup option to folder backup)
@echo off
copy client*.csv D:\mergetest\csv\backup
copy ready.csv client1.csv
copy ready.csv client2.csv
copy ready.csv client3.csv
del sync.csv
copy ready.csv D:\mergetest\csv\backup
del ready.csv
exit
makephonebook.bat (main bat file, that launches all processes)
@ECHO OFF
START "" sync.bat
ping 127.0.0.1 -n 10 >nul
start /w wscript.exe "cleanfile.vbs"
ping 127.0.0.1 -n 10 >nul
START "" deduplicate.bat
ping 127.0.0.1 -n 10 >nul
START "" clean.bat
exit
6) On server add makephonebook.bat to tasks list WHEN ALL YOUR CLIENTS ARE NOT ONLINE, for example in 2:00 AM, or run it manually after closing all PhonerLite copies on PCs in your network
7) Have fun!