Hello Chris,
You can achieve this by doing the following:
1) On the Install Parameters page create a new property called LIBDIR
2) Create the interface necessary for the user to select the lib directory. You can achieve this by
creating a browse button. Store the selected folder's path in LIBDIR instead of MY_DIR (the property from the example)
3) On the Environment page, create a new environment variable with these settings:
Code: Select all
Name: MYCLASSPATH
Value: [LIBDIR];[LIBPATHS]
This will add the library folder and all of its subdirectories to the MYCLASSPATH environment variable
4) On the Custom Actions page, make the InstallInitialize standard action visible by right clicking in the tree->Show Standard Action->Before File Installation->InstallInitialize
5) Now place the following two custom actions under InstallInitialize:
a) A
CreateExeProcess custom action with the following in the Action Data field:
Code: Select all
[LIBDIR]>cmd /c dir /s /b /a:d>"[TempFolder]libs.txt"
This will list the directories in the folder selected by the user and write them in the libs.txt file located in the user's temporary folder
b) A VBScript
Attached Custom Action with the following code:
Code: Select all
'Holds the path of the directory
Dim directoryListing
directoryListing = Session.Property("CustomActionData")
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(directoryListing, ForReading)
Dim classpath
'initialize classpath
classpath = objFile.ReadLine
Do Until objFile.AtEndOfStream
classpath = classpath & ";" & objFile.ReadLine
Loop
Session.Property("LIBPATHS") = classpath
objFile.Close
The above code needs to be placed in a .vbs file. In this custom action's Action Data field you would have to place "[TempFolder]libs.txt" without the quotes, so that our script knows which file to read the directory structure from. Upon finishing, this custom action will set the LIBPATHS property to the list of directories in the folder selected by the user, separated by ";"
Attached is a sample project that implements this.
Let me know if there is anything else I can help you with.
Regards,
Gabriel
FOLLOW US
Get the latest news in Application Packaging