How to Deploy 3CX client without using Welcome Email

Discussion in 'Windows' started by dan_tx, Dec 3, 2017.

Thread Status:
Not open for further replies.
  1. dan_tx

    Joined:
    Nov 3, 2016
    Messages:
    84
    Likes Received:
    22
    In a past post I talked about deploying 3cx windows client and customizing it via scripts. Mainly to have things like chat window pop up and other settings the same across all users.
    See thread here for that

    https://www.3cx.com/community/threa...ze-provision-and-deploy-the-3cx-client.47499/

    One thing that was an issue was how do you get the .3cxconfig files to automatically deploy it without having to manually go through the console and click the "Config+" and save it. What if you had 300 users? Not possible right?

    Well below are the steps to automate it. There are some certain things that have to be done manually, but the bulk work is done via scripts or other.

    1. Get the .3cxconfig files for all your users.
    To do this download Test Mail Server Tool at http://www.toolheap.com/test-mail-server-tool/
    Run it on a pc on the same network of your 3cx server.
    Go into the 3cx server and change the SMTP server to that pc's IP address.
    Select the folder in Test Mail Server Tool you want the emails saved in.
    Go into the 3cx Console and select every extn and send that Welcome Email.
    You will get all those welcome emails in .eml format from the server tool. The good news is the extension number for each welcome email is the last 4 characters of the file. So 3cxProv_******_1100.eml is for extension 1100.

    So you have the Welcome Emails, now you need those config files. Go get UUD32win http://www.marks-lab.com/
    This program extracts the config file as a .htm file.

    Once you have the .htm files, you need to rename them to end in .3cxconfig. If you want to deploy them using scripts and need them to be named the users login name, below is how I did it all at once. Basically used excel to make a big cmd that renamed all the files in the folder to the (username).3xcxconfig The interesting part was matching the extension with the username, again done in excel with the VLOOKUP function.

    Below are the main functions. If your not comfortable using excel, then this might not be for you. I'm sure you can script this another way, but this is how I did it.
    To get a list of the files to start with do "dir > files.txt" in the command prompt. Copy the file list and paste into excel
    Export your extensions from 3cx console so you have a list of everyone. I'd delete everything out of the spreadsheet but the usernames (their emails minus the @***) and their exten numbers.
    Now you just have to create a vlookup and match the username/ext with the file name based on the last 4 digits in the .html file. Then use the CONCATENATE function to modify the name and add the "ren" to the beginning so you can copy it all and run it as a cmd to rename all the files.

    Some functions and what i used them for in excel are
    remove junk in file name except exten.htm =RIGHT
    get rid of .htm =LEFT
    get the current file name and name I want it to be in a REN cmd =CONCATENATE("ren ",CHAR(34),E1,CHAR(34)," ",CHAR(34),D1,F1,CHAR(34))

    And the main one Vlookup. This compares your column with exten and users you pulled out of 3cx to your column of file names from the welcome email. It then makes a new column you can reference of users names that are lined up with the extensions from the welcome email. A few CONCATENATE functions then get you to the command to rename the files to matching usernames based on extension.

    =VLOOKUP(A1,$B$1:$C$86,2,FALSE)
    example
    upload_2017-12-3_16-21-49.png


    Now you have a bunch of (username).3xconfig files after renaming them using command prompt and pasting in the text you get from excel. Obviously secure these files, they contain 3cx login information for all your users.

    Put those in a shared path and now you can run scripts to automatically provision every pc on your network with the 3cx client. If a user has logged into the PC in the past and has a C:\Users\(username) folder, you can drop the proper 3cx files into their folder so when you login, 3cx launches with their extension, even if they never opened the Welcome Email on that pc before.

    I've made some changes to the script I originally used, the new one is below and is better. I had some issues with the past one in some situations and it wasn't as fast.
     
  2. dan_tx

    Joined:
    Nov 3, 2016
    Messages:
    84
    Likes Received:
    22
    Below is the updated script. It also is set to change the settings like the header image or anything else via the powershell script. For more details on this you can see the previous thread mentioned in the first post on this thread. You must replace (USER) with the user that runs the script and (NWPATH) with the path you put the files on it's referencing.
    Code:
    rem  Step 1
    taskkill /FI "WINDOWTITLE eq 3CX*" /F
    
    rem Step 2
    cd C:\users\
    
    rem Step 3
    if exist C:\temp\users.txt del /f C:\temp\users.txt
    dir /b > C:\temp\users.txt
    
    rem Steps 4-11
    cd c:\temp
    for /F %%E in (C:\temp\users.txt) do (if exist %%E.3cxconfig del /f %%E.3cxconfig && timeout /t 3)
    if exist "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml.back" del /f "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml.back"
    if exist "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml" del /f "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml"
    
    for /F %%A in (C:\temp\users.txt) do (if exist "(NWPATH)\%%A.3cxconfig" robocopy /njh /njs /ndl /nc /ns "(NWPATH)" "c:\temp" %%A.3cxconfig)
    cd C:\temp\
    taskkill /im 3CXWin8Phone.exe /f && taskkill /im 3CXWIN~1.exe /f
    
    :del3cxphone
    if exist "C:\users\(USER)\appdata\Roaming\3CXPhone for Windows\3CXPhone.xml.bak" del /f "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml.back"
    if exist "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml"  del /f "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml"
    
    for /F %%C in (C:\temp\users.txt) do (
        if exist "C:\Users\(USER)\AppData\Roaming\3CXPhone for Windows\" (
            rmdir /s /q "C:\Users\(USER)\AppData\Roaming\3CXPhone for Windows\"
            )
        if exist %%C.3cxconfig (
            del /f "C:\Users\(USER)\AppData\Roaming\3CXPhone for Windows\*" /s /q
            start %%C.3cxconfig (
                timeout /t 5
                ping localhost -n 5 >NUL
                taskkill /FI "WINDOWTITLE eq 3CX*" /F
                taskkill /im 3CXWin8Phone.exe /f
                taskkill /im 3CXWIN~1.exe /f
                copy "C:\Users\(USER)\AppData\Roaming\3CXPhone for Windows\3CXPhone.xml" "C:\Users\%%C\AppData\Roaming\3CXPhone for Windows\3CXPhone.xml"
                timeout /t 2
                ping localhost -n 5 >NUL
                rmdir /s /q "C:\Users\(USER)\AppData\Roaming\3CXPhone for Windows\"
                )
            )
    )
    if exist "C:\Users\(USER)\AppData\Roaming\3CXPhone for Windows\3CXPhone.xml" rmdir /s /q "C:\Users\(USER)\AppData\Roaming\3CXPhone for Windows\"
    )
    del /f "C:\temp\%%C.3cxconfig" && timeout /t 3 && ping localhost -n 10 >NUL
    del /f "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml.back"
    del /f "C:\users\(USER)\appdata\roaming\3cxphone for windows\3CXPhone.xml"
    
    rem Step 12
    del /f "C:\temp\users.txt"
    
    taskkill /FI "WINDOWTITLE eq 3CX*" /F
    
    rem Step 13
    rem cd C:\temp
    
    rem for /d %%B in (C:\Users\*) do if exist "%%B\AppData\Roaming\3CXPhone for Windows\" cd %%B\AppData\Roaming\3CXPhone for Windows && robocopy "(NWPATH)" C:\temp 3cxscript.ps1 && robocopy "(NWPATH)" "C:\ProgramData\3CXPhone for Windows\PhoneApp" HeaderImage.jpeg && powershell -ExecutionPolicy ByPass -File .\3cxscript.ps1
    
    rem del /f /s /q "C:\temp\3cxscript.ps1"
    
    :end
     
Thread Status:
Not open for further replies.