breedj
Posts: 3
Joined: Thu Jun 18, 2009 9:21 am

How to use File Search in custom action Expression

I've made a custom action dll, which works fine. The custom action dll is put in the [APPDIR] and the custom action is defined in InstallExecuteSequence-->Uninstall with the expression (NOT Installed). This works very well. But sometimes one of my customers says they get an error saying the the installer cannot find the customactions.dll (.NET) which holds my custom actions. The uninstall then rollsback and the customer is therefore not able to uninstall.

So my idea was to add an extra check before invoking the custom action. I want the custom action only to run if the dll is physically present when the progam is uninstalled. So I added the expression 'AND (?SetupCustomActions.dll =3)'. I seems that if I test this by renaming/removing the actual dll the custom action is still executed, which results in the error. I assume that the component state is not affected if the actual file is removed. Am I right?

My next idea was to add a file search and check the state of the search in the expression of the custom action. So I added a File Search called 'CAPRESENT' (Name: SetupCustomActions.dll, Folder: [APPDIR], Depth: 1). I also added the standard action 'AppSearch' under InstallUISequence (I read somwhere on the forum that without it the file search is not executed.) Then I tried the expressions AND (CAPRESENT) and also AND (CAPRESENT <> ""). Both do not work the expression evaluates as 'false' for both.
What am I forgetting or doing wrong?

I was also wondering if I could embed custom action dll files in the installer so they can be used during the (un)installation, but are not put in the app folder?
Since the SetupCustomActions.dll is only used during the (un)install. That way I also want to make sure that the dll is always present because it will be unpacked every time the (un)install is initiated. Now I put the dll in the appdir when installing and are relying on the file to be still present when uninstalling. Is there some way to do that?

Thanks in advance!
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to use File Search in custom action Expression

Hi,
The custom action dll is put in the [APPDIR] and the custom action is defined in InstallExecuteSequence-->Uninstall with the expression (NOT Installed)
When do you want to run the custom action, during install or during uninstall? Note that the uninstall condition is:

Code: Select all

REMOVE = "ALL"
But sometimes one of my customers says they get an error saying the the installer cannot find the customactions.dll (.NET) which holds my custom actions.
I'm not sure why this happens. Can you please send us the .AIP (project) file you are using to support at advancedinstaller dot com so we can investigate it?
I assume that the component state is not affected if the actual file is removed. Am I right?
Yes, the component is not affected if the file is removed manually.
So I added a File Search called 'CAPRESENT' (Name: SetupCustomActions.dll, Folder: [APPDIR], Depth: 1).
Please note that the APPDIR property can be used only after the "CostFinalize" standard action. Since the "AppSearch" standard action (the one which performs the search) is scheduled before "CostFinalize", a search cannot use the APPDIR property.
I also added the standard action 'AppSearch' under InstallUISequence (I read somwhere on the forum that without it the file search is not executed.)
Please note that the "AppSearch" standard action is included by default in the installation. You can show it in the "Custom Actions" page if you want to schedule custom actions under it or if you want to condition it.
I was also wondering if I could embed custom action dll files in the installer so they can be used during the (un)installation, but are not put in the app folder?
This can be done only for C++ DLL custom actions. If you have a C++ DLL you can add it as a New Attached Custom Action in order to embed it into the installer. Other types of DLLs need to be present on the target machine when the custom action runs.
Now I put the dll in the appdir when installing and are relying on the file to be still present when uninstalling. Is there some way to do that?
To make sure that a file is not removed during uninstall you can mark its component as permanent or as not registered with Windows Installer.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
breedj
Posts: 3
Joined: Thu Jun 18, 2009 9:21 am

Re: How to use File Search in custom action Expression

Please note that the APPDIR property can be used only after the "CostFinalize" standard action. Since the "AppSearch" standard action (the one which performs the search) is scheduled before "CostFinalize", a search cannot use the APPDIR property.
Is there any way to check the presents of a file in appdir before the execution of a custom action while uninstalling?

Thanks!
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How to use File Search in custom action Expression

Hi,

Yes, you can try using a custom action. The path of APPDIR can be written in the registry during the install process and retrieved during uninstall through a search (for the registry entry). This way the custom action knows the installation folder.

For detecting a file you can find some sample VBScript code here.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
breedj
Posts: 3
Joined: Thu Jun 18, 2009 9:21 am

Re: How to use File Search in custom action Expression

Thanks! I can use that.

Return to “Common Problems”