Abort installation if file does not exist - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

BobCrothers
Posts: 66
Joined: Wed Dec 05, 2007 10:58 pm

Abort installation if file does not exist

Hi Gurus,

Our customers are supposed to put a properties file in the same directory as the install program. The install program installs our files and copies the properties file to the correct location as part of the install. We would like for the install program to check for the existence of the properties file. If the file does not exist, display a dialog and abort the installation. I have created a file search, the name is the name of the properties file, and the path is [SourceDir]. This displays a dialog and aborts, this is terrific. The problem seems to be that “SourceDir” has not been set at this point. As a result, the installer NEVER finds the file and never installs. By experimenting I see that “OriginalDatabase” is set and has close to what I need. I wrote a vb script to pull the path out of “OriginalDatabase” and append the property file name. But I don’t see how to use the vb script as a search or in custom launch conditions.

How can I tell if a particular file exists in the directory where the msi is located and abort the install if the file does not exist?

Thank You
Bob
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Abort installation if file does not exist

Hi Bob,

There is really no need for a vbscript to achieve this. I have attached a sample project that does this. I hope you find it of use.

Best regards,
Gabriel
Attachments
sample.zip
(2.7 KiB) Downloaded 515 times
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
BobCrothers
Posts: 66
Joined: Wed Dec 05, 2007 10:58 pm

Re: Abort installation if file does not exist

Thank you Gabriel, but I still have a problem.

I tested your sample, and it works great, it does what I want. I moved the vb script and custom action into our project. It did not work. We have “Limit to basic user interface (simple progress and error handling)” checked. This is the problem. If I uncheck “Limit to basic user interface” then the abortinstall.vbs works great.

To summarize, I started with a search for the properties file. The search was called as a “Custom Launch Condition” under prerequisites. This does display a dialog. But it fails because SourceDir is not set at that time. Following your suggestion, I used the same file search and added a custom action after CostFinalize. The SourceDir is set at this time, and dialog displayed. But if “Limit to basic user interface” is checked the vb script is not called and the test fails.

Is there a way around this problem? Abortinstall.vbs works great, but it is not called if limited user interface.

Thanks
Bob
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Abort installation if file does not exist

Hello Bob,

Sorry about that, it seems I forgot to take into account the fact that there is no InstallUISequence in a limited user interface.
Note the change in approach:
- the search for the file is no longer done via AppSearch. The vbscript does that. This is because the project would get too complicated if AppSearch were to be used. Standard action order would have to be changed to take into account that SOURCEDIR is resolved after AppSearch which would need SOURCEDIR resolved.
- note the ResolveSourceDir which manually resolves SOURCEDIR. This is because SOURCEDIR doesn't seem to be automatically resolved during this phase.
- also note that there is no InstallUISequence so we have to duplicate the file check

Regards,
Gabriel
Attachments
sample.zip
(305.71 KiB) Downloaded 423 times
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
BobCrothers
Posts: 66
Joined: Wed Dec 05, 2007 10:58 pm

Re: Abort installation if file does not exist

Thanks Gabriel, this works great.

Return to “Common Problems”