Antarctica
Posts: 110
Joined: Tue Jul 08, 2014 9:24 am

Check if file exists before doing search

I have found that using a search I can check whether a file exists: viewtopic.php?t=11221

However, I have to do the actions in the following order:

- Check whether an XML file exists
- If it exists, call custom actions to modify XML file.
- Do XML search on file.

How can I achieve this?

(Before you tell me that I should just do the XML search in my custom action: The custom action is "Launch file" "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -pd connectionStrings" to decrypt the passwords in the XML file before doing XML search to auto-fill the corresponding dialogs windows. This may only be executed if the Web.config exists, because otherwise an XML file stub is created during decryption, and then the XML element order is wrong and the IIS won't work after install.)
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Check if file exists before doing search

Hello,

You could implement this scenario in the following way:

- for checking whether an XML file exists, create a new file search from "Searches". The default property associated with this file search is "RESULT_PROPERTY". If the file is found, the result property will store the full path of the file.
- for modifying the XML you could use an "Launch File" custom action, as you've said. You could condition the execution of this custom action with "RESULT_PROPERTY". In this way the custom action will only be executed if the file is found.
- You could implement the XML search using our XML Search from "Searches" page. For more details, take a look on this tutorial : Creating an XML Search

As regarding the order of these three actions in the install sequence, the file search is done during the AppSearch Standard Action and the XML search is done by an Advanced Installer Custom action : "AI_XmlLocator". These two actions are present in both "InstallExecuteSequence" and "InstallUISequence". If the package is installed with UI, the searches will be performed during "InstallUISequence". If the package is installed silently, the searches are performed during "InstallExecuteSequence".

In order to implement the order you've mentioned you have to modify the sequence of the Launch File custom action from "Table Editor" page so it would execute after "AppSearch" and before "AI_XmlLocator" in both "InstallExecuteSequence" and "InstallUISequence"

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”