How to get a free TCP port by using a custom action
The following article uses options that are available starting with the Enterprise edition and project type.
If you install a server application that uses a TCP IP protocol for communication is better to know before installation starts that the port you want to use is free. Using Advanced Installer you can get a free TCP port using GetFreeTCPPort predefined custom action.
Go to the Custom Actions page and add the predefined UI Custom Action "Get free TCP Port".
Go to the Dialog Editor page.
Create a new dialog called "GetFreeTCPPort", added after "WelcomeDlg" in the dialogs tree.
Bind the port edit control to the AI_SEARCH_TCP_PORT property. The Get free TCP Port custom action gets the starting port from which the search starts from AI_SEARCH_TCP_PORT property. Bind the static text controls to the RESULT and RET properties.
Select the "Get" button and the following "Published events" as in the image below:
Sample Project
You can find a small sample Advanced Installer project implementing the above functionality here.