erichuff

text file update?

Is there a way to do a conditional update of a text file? For example, I have a text file that has a line in it that is "C:\Program Files (x86)\...". Can I do something where if the OS is 32-bit to modify that line to be "C:\Program Files\..." instead?

Thanks.
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: text file update?

Hello and welcome to Advanced Installer forums,
Is there a way to do a conditional update of a text file? For example, I have a text file that has a line in it that is "C:\Program Files (x86)\...". Can I do something where if the OS is 32-bit to modify that line to be "C:\Program Files\..." instead?
Unfortunately, we do not have predefined support for this. However, this can be achieved. Here is the logic:
Capture.PNG
Capture.PNG (16.34 KiB) Viewed 5895 times
As you can see in the above screenshot, a text file update can be condition to run based on one of the following:

1. component install
2. component uninstall
3. component install and uninstall

By following the above logic, we firstly need to condition our text file update based on a component. Fortunately for us, a component can also be conditioned. This component will be conditioned based on the bitness of the Operating System. The component can be conditioned based on the following property:

VersionNT64

This property is set to the version number for the operating system only if the system is running on a 64-bit computer (it is empty if the package runs on a non-64 bit computer).

We can use this property as it follows:

VersionNT64 --> means that the OS is 64-bit

NOT VersionNT64 --> means that the OS is 32-bit

The second condition will be the one that we will use since you want to condition the text file update based on whether the OS is 32-bits or not.

Now that we have explained the logic here, let's implement it in our project.

First thing that you need to do is to add an empty text file to your project.
Capture2.PNG
Capture2.PNG (48.51 KiB) Viewed 5895 times
After doing so, please go to "Organization" page and find the newly created component for your file.
Capture3.PNG
Capture3.PNG (79.17 KiB) Viewed 5895 times
As you can see, this component has a "Condition" field. In that condition field, we will use the previously explained condition:

NOT VersionNT64

Now, this component will only install if the OS is a 32-bit OS.

Now, please go back to "Files and Folders" page and create the text file update. Condition it to run during the installation of our previously created component (which will install only if the OS is 32-bit) => the text file update will only take place if the OS is 32-bit.
Capture4.PNG
Capture4.PNG (15.87 KiB) Viewed 5895 times
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”