Hi Karl,
I have already tried this out, but i keep getting this error on install;
Cannot create the directory c:\folder\subfolder\ourfile.exe. A file with this name already exists. Please rename or remove the file an click retry, or click cancel to exit.
This is because the File Search returns the full path of the file if it is found (such as "c:\folder\subfolder\yourfile.exe") and will try to create a folder with the same name ("yourfile.exe") under that path ("c:\folder\subfolder\").
You need to use a Custom Action that will extract the full path of the file and use that to create the "Property Based" folder.
These are the required steps:
1. In the Search page, create the File Search on all drives (or use the Search wizard). I shall assume that the search result is stored by the Property "FILEFOUND".
2. Create a new text file ("ExtractFolder.vbs") and copy the following code into it:
Code: Select all
strFullPath = Session.Property("FILEFOUND")
strFolder = ExtractFolder(strFullPath)
Session.Property("FILEFOUND") = strFolder
' MsgBox strFolder
Function ExtractFolder(strFullPath)
Dim pos, strFolder
pos = InStrRev(strFullPath,"\")
strFolder = Left(strFullPath, pos)
ExtractFolder = strFolder
End Function
Make sure that you change the name of the Property ("FILEFOUND" in this case) to the one that holds the Search result in your case.
3. In the Custom Actions page, make sure that "AppSearch" tree item is visible under both "InstallUISequence" and "InstallExecuteSequence". If not, right click on each sequence item and select "Show Standard Action" -> ...)
4. Righr-click on one of the "AppSearch" items and select "New Attached Custom Action", then select the VBScript file you have created previously. Set the following properties for this Custom Action:
- Function Name: (Must be blank)
- Execution Properties: "Synchronous execution, check return code"
- Scheduling Options: "Execute only once if present in both sequence tables"
- Execution Condition: FILEFOUND (or whatever Property holds the Search result in your case)
5. In the tree control, drag and drop this Custom Action to the other "AppSearch" tree node, by holding the "SHIFT" key pressed. Make sure that this Custom Action has the
same properties as specified above ("Execution Condition" etc).
Although this CA appears twice (in both sequence tables), it will be executed only once.
6. In the Files and Folders page, create the "Property Based" folder.
Hope this helps.
Regards,
Denis