How do I check if file exist and write an INI values - 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!

capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

How do I check if file exist and write an INI values

Hi,

My installer has a requirement where i need to check if a file exists then create an INI files with certain values. I found a vb script that shows how to check the existence of a file either ways
Re: Abort installation if file does not exist - posted 10th Nov, 2009
and I have worked out that I could use
standard action - WriteINIValues
but this is where i have drew a blank because i couln't find appropriate examples. Question, am I on the correct track, if yes please share with me an example. Furthermore, if there is a better way to write my INI file please share with me.

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

Re: How do I check if file exist and write an INI values

Hello,

You can check the existence of a file by using a Search. Our tutorials in the user guide are quite helpful for beginners, so that would be a good place to start learning. They will help you with using Advanced Installer proficiently.
Let me know if there are things that are unclear in the user guide, and will do my best to assist.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How do I check if file exist and write an INI values

Hi Gabriel,

I want to perform 2 actions, first search for a file in the target location at the end of the installations of file and followed by writing an INI. I have found an example vb script that does the search for me - and i am happy with this - all i need is help to connect the result of the search with the action of write an INI file/entries.

Your online help is too light weight it does go deep enough for advanced users. I am doing nothing but read and print your help file content which is the same as your online help - some times it helps when the task is simple other times when task are a little involved it fails.

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

Re: How do I check if file exist and write an INI values

Hello,

Please note that our user guide does not cover every possible scenario a user could encounter. It is not possible to do so. What we can do in our user guide is explain the usage of tools Advanced Installer puts at your disposal and also cover some very common scenarios like conditionally installing a file and other such cases. We believe it is up to the user to figure out which tool should be used when, and in what combination with other tools.

Since you are using a VBScript, you can use Session.Property("YOURPROPERTY") to get or set the value of YOURPROPERTY from inside the script. Your search can store there result in a property like this, which you can later user in your INI file.

Let me know if this works for you.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How do I check if file exist and write an INI values

Hi Gabriel,

Your user guide is rich with definitions which is good as a start point but then advanced users would want to use these and would definitely need examples to start them off. So for examples, Standard Action "WriteINIValues" is well explained:
WriteINIValues -> creates INI files or entries specified in the Files and Folders page
However, how is this CA used? I know how to create INI from File and Folders ! The burning point on my mind is, clearly, CA - WriteINIValues - is an action triggered/or not triggered as a result of a previous test - so if i am correct how is this done and how is the INI values written.

I read you last post and i believe you are asking me to define a feature with my INI values then either use the search result or my vb script to trigger the installation of this feature to create my INI values. Well, I figured this out before but I thought it would be a wasteful use of features since creating the INI values would be the only action that would fit into this scenario.

I realize that Advanced installer is just a GUI implementation for MS Windows installer and there are limits and I have been around for long enough to know that. But my background is programming and my last installer, InstallMaster, by wise solutions which allowed to perfrom a lot of programming, like [perform test - using if statements] --> [result would then trigger an action or do nothing]. So I am looking for assistance from Advanced Installer experts like yourself to help me squeeze every single drop out of your software. Within the last 4 weeks i have read your user guide many times over. So i look forward to your help.

Thanks

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

Re: How do I check if file exist and write an INI values

Hi again Moshud,

The thing is, WriteIniValues is not a custom action. It is a standard action, meaning Windows Installer does that action. It is actually responsible for creating the INI file you are configuring from the Files and Folders page.
I read you last post and i believe you are asking me to define a feature with my INI values then either use the search result or my vb script to trigger the installation of this feature to create my INI values. Well, I figured this out before but I thought it would be a wasteful use of features since creating the INI values would be the only action that would fit into this scenario.
Not exactly. I was thinking more of using a component. Features are visible to end-users, meaning they can select them to be installed or not (usually). Components are part of features, they are not visible to end-users and are easier to condition for installation using your search result property.

I have no doubt you've carefully read our guide, however we are exposing a lot of functionality available in Windows Installer. There are things that, even if documented in our user guide, can't fully be understood unless experimented first-hand, which is why we actually recommend users to follow the tutorials there.

Regardless, we're here to help clarify issues and guide our users on the right path :)

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How do I check if file exist and write an INI values

Hi Gabriel,
... can't fully be understood unless experimented first-hand, which is why we actually recommend users to follow the tutorials there
And I concur. I started off with your simple tutor then progress to the professional version and now i need more help since your tutorials can't deal with every single scenario.

So please can you put together for me a simple search and the result trigger a component that would write an INI value.

Trying to learn more:
Not exactly. I was thinking more of using a component. Features are visible to end-users, meaning they can select them to be installed or not (usually). Components are part of features, they are not visible to end-users and are easier to condition for installation using your search result property.
I had in mind to set feature field "Feature tree" = "Not Displayed" to keep away from user selection. however, i am interested in knowing how to condition a component not to install by default and only install based on search result.

I appreciate your help.

Thanks

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

Re: How do I check if file exist and write an INI values

Hi Moshud,

On the Files and Folders page, right-click your INI file, select "Go to Component". You will be taken to the Organization page, with the component in which your INI file resides selected. On the right pane, under the "General" group there is the Condition field. Based on the condition you provide here, the component will or will not be installed. Assuming you've made a file search named MY_FILE_SEARCH, you can place MY_FILE_SEARCH in the condition field. If the property is empty, the condition will evaluate to false and the component will not be installed. If the search is successful, the MY_FILE_SEARCH property will not be empty and the condition will evaluate to true, thus the component will be installed.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How do I check if file exist and write an INI values

Hi Gabriel,

An INI values resource file can't be contained in it's own component therefore the search result would install or not the host component. I have tried to force a new component for my INI values but "Move to a new component" is disabled for INI values. So how to I get around this obstracle or have i missed something?

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

Re: How do I check if file exist and write an INI values

Hello,

Indeed, you can not force an INI into it's own component. You will need to create some dummy resource, say a dummy registry value and place the INI along with the registry value in the same component.

Let me know if that works for you.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How do I check if file exist and write an INI values

Hi Gabriel,

Okay that sounds logical. My search depends on the app folder selected on "FolderDlg" dialog therefore how can i schedule a search at "Next" button event? I am assumming that the generic search takes place at the beginning of the installation. Please be more explicit as to how schedule a search.

Thanks

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

Re: How do I check if file exist and write an INI values

Hi Moshud,

Searches are all executed at the beginning of the install, by the AppSearch standard action. You simply need to define the search from the Search page. That's all. The search will complete and the search's property will be available for the rest of the install process.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How do I check if file exist and write an INI values

Hi Gabriel,

I followed your instructions but my search failed though the search condition is present. Below are links to my .exe and .msi while .aip is attached for your inspection and your advise. Don't worry this is a small tester installer i used to test ideas before migrating them to my actual installer. Perhaps you might find out where i am going wrong.

I am search for "cpsetup.cul" in "Tutor" folder, a subfolder of application folder. I defined a search location and selected "Tutor_DIR" with depth eqauls 0.

The component (sp.exe) used under "Common" feature to test if search result would install component or not. What i experience is the search fails everytime hence the component never installs.

You won't need to make any selection during installation session just select "Next" until it installs.

http://www.capesystems.com/moshudx10/CA ... Action.vbs
http://www.capesystems.com/moshudx10/testProject2.exe
http://www.capesystems.com/moshudx10/testProject2.msi

A separate question not to be mixed with the above; I understand that search be scheduled at beginning of the installation. Question: can a secondary search occur just before files are installed or when buttons are clicked? If yes, how?

Thanks
Attachments
testProject2.aip
(20.92 KiB) Downloaded 771 times
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How do I check if file exist and write an INI values

Hello,

I am afraid you can not use properties inside of a search unless the property's value is already define in the Install Parameters page, or you are sure it exists when AppSearch is executed. Thus, you can not use Tutor_DIR as a search location.

I am afraid you will need create a custom action to do the search for you.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
capeuk
Posts: 35
Joined: Tue Jun 15, 2010 11:13 am
Location: London, UK
Contact: Website

Re: How do I check if file exist and write an INI values

Thanks.

Return to “Common Problems”