karl
Posts: 3
Joined: Mon Nov 28, 2005 1:15 pm

replacing a file

Hi

I am new to advanced installer, and I am faced with a problem at the moment which I would think is very easy to solve, but I have had no luck with it so far myself.

Basically, I want to run an msi that updates a .exe application file within a specific folder on the destination PC.

I would also like to know how to use the search feature properly. I understand from reading other posts that the search feature should be able to find a folder on the destination machine, and run the msi package adjusting the destination to output the .exe application update to.

Any help with this would be very much appreciated.

Many thanks


Karl
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Hi,
Basically, I want to run an msi that updates a .exe application file within a specific folder on the destination PC.
In the Files and Folders page in AI, add the new EXE file to the appropriate directory (it can be "Property Based") where the old file resides. Windows Installer will use the File Versioning Rules to determine whether the old file will be replaced or not. See the following page for details and determine which of the versioning rules apply in your case:
http://msdn.microsoft.com/library/defau ... _rules.asp

Regarding the Search feature, you can use the wizard (accessible through Wizard -> Search). The result of the Search can be used to create a "Property Based" folder (in the Files and Folders page) or create a Directory Set with Formatted Custom Action (in the Custom Actions page).

Hope this helps.

Regards,
Denis
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/
karl
Posts: 3
Joined: Mon Nov 28, 2005 1:15 pm

Thankyou very much for your help. After spending some time looking for the wizard, I realised I did not have the latest version of AI. I now have the latest version, along with the wizard feature, which now gives the reply you sent me a lot more meaning.

I have managed to get the search facility to find a specific folder on the destination machine, and write to it. I now need to know what to do when I dont know the folder name on the destination machine.

Basically, our application is on many machines throughout the country. Some people change the folder name that our application resides in, so a folder search will be no good for the task I want to do. Regardless of the folder name, there is a .exe file that resides in the folder, which always has the same file name, and is never changed by the user.

I want to know if it is possible to add files / folders to whatever folder our .exe file resides in by doing a file search for the .exe file on the machine.

I have already tried this out, but i keep getting this error on install;

Cannot create the directory c:\folder\subfolder\ourfile.exe. A file with this name already exists. Please rename or remove the file an click retry, or click cancel to exit.

Is all I have done to test the build is to create a file search in AI for 'ourfile.exe' on all fixed drives. I then created a property based folder taken from the result of the file search, and placed a random file in that folder. I wanted to see if it would find the required file on the destination machine, and put the random file into the same folder as the file that was found.

I am not entirely sure what I am doing wrong, and I dont understand why I am getting the error mentioned above, as I have not included the ourfile.exe into the build anywhere, so their should be no reason why it should be trying to replace that file.

Any further help with this file would be very much appreciated. I hope I have explained my situation well.
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Hi Karl,
I have already tried this out, but i keep getting this error on install;

Cannot create the directory c:\folder\subfolder\ourfile.exe. A file with this name already exists. Please rename or remove the file an click retry, or click cancel to exit.
This is because the File Search returns the full path of the file if it is found (such as "c:\folder\subfolder\yourfile.exe") and will try to create a folder with the same name ("yourfile.exe") under that path ("c:\folder\subfolder\").

You need to use a Custom Action that will extract the full path of the file and use that to create the "Property Based" folder.

These are the required steps:

1. In the Search page, create the File Search on all drives (or use the Search wizard). I shall assume that the search result is stored by the Property "FILEFOUND".

2. Create a new text file ("ExtractFolder.vbs") and copy the following code into it:

Code: Select all

strFullPath = Session.Property("FILEFOUND")
strFolder = ExtractFolder(strFullPath)
Session.Property("FILEFOUND") = strFolder
' MsgBox strFolder

Function ExtractFolder(strFullPath)
  Dim pos, strFolder
  pos = InStrRev(strFullPath,"\")
  strFolder = Left(strFullPath, pos)
  ExtractFolder = strFolder
End Function
Make sure that you change the name of the Property ("FILEFOUND" in this case) to the one that holds the Search result in your case.

3. In the Custom Actions page, make sure that "AppSearch" tree item is visible under both "InstallUISequence" and "InstallExecuteSequence". If not, right click on each sequence item and select "Show Standard Action" -> ...)

4. Righr-click on one of the "AppSearch" items and select "New Attached Custom Action", then select the VBScript file you have created previously. Set the following properties for this Custom Action:
- Function Name: (Must be blank)
- Execution Properties: "Synchronous execution, check return code"
- Scheduling Options: "Execute only once if present in both sequence tables"
- Execution Condition: FILEFOUND (or whatever Property holds the Search result in your case)

5. In the tree control, drag and drop this Custom Action to the other "AppSearch" tree node, by holding the "SHIFT" key pressed. Make sure that this Custom Action has the same properties as specified above ("Execution Condition" etc).

Although this CA appears twice (in both sequence tables), it will be executed only once.

6. In the Files and Folders page, create the "Property Based" folder.

Hope this helps.

Regards,
Denis
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”