Problem with setting application folder - Advanced Installer Community
d.caddell
Posts: 6
Joined: Tue Mar 12, 2013 3:51 pm

Problem with setting application folder

I am having trouble getting my Application Folder path set to a value created a custom Action. I am trying to follow the method used here: http://www.advancedinstaller.com/forums ... =5&t=21568

I have created a File to Search called MY_FILE and it is able to find the path of the file I specified. Now I want to set the Application Folder path to the Parent folder of the file found. I created script called Search.vbs and used this code:

Code: Select all

Function GetParentFolder()
  filePath = Session.Property("MY_FILE")
  Set objFS = CreateObject("Scripting.FileSystemObject")
  If (objFS.FileExists(filePath)) Then
    Session.Property("PARENT_FOLDER") = AppendTrailingBackslash(objFS.GetParentFolderName(filePath))
  End If
End Function

Function AppendTrailingBackslash(folderPath)
  If Right(folderPath, 1) <> "\" Then
    AppendTrailingBackslash = folderPath & "\"
  Else
    AppendTrailingBackslash = folderPath
  End If
End Function
Then I created a custom action to launch the attached file Search.vbs

The Function is called GetParentFolder
Execution time is set to Immediately

On the install parameters Properties I added a Property Called PARENT_FOLDER with a value of MY_FILE. I am stuck when I run the install I get the error "Could not access network location MY_FILE."

Please Help.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Problem with setting application folder

Hello,

This may happens because the Value field from the edit property dialog is of pseudoFormatted data type. The Properties referenced by
PseudoFormatted data types are resolved at build time while properties referenced by Formatted data types are resolved at runtime.

Please note that I used the predefined Execute inline script code custom action with sequence added after the Searches from the Install Execution Stage and I manage to get the folder path where that file was installed.

Code: Select all

 Session.Property("FLD_PTH") = Left(Session.Property("FILE_PTH"), InStrRev(Session.Property("FILE_PTH"), "\")-1)
where:
  • *FILE_PTH is the property assigned to the file search operation in the Search page (e.g. C:\program\editor\program.exe ).
    *FLD_PTH is a public property that will contain the parent folder path of the searched file (e.g. C:\program\editor).
I assume you want to install files into a custom folder.In order to achieve that you can go in the Files and Folders page and add a Property based folder using the FLD_PTH property. Property based folders will be resolved at install time to the values from the respective property.

Please let us know if that helped otherwise please attach a sample which replicate this scenario and a test case so I can have a better view about this.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
d.caddell
Posts: 6
Joined: Tue Mar 12, 2013 3:51 pm

Re: Problem with setting application folder

I tried changing it to the inline script but still getting the same issue. Added aip for reference
Attachments
LT2500D.aip
(30.62 KiB) Downloaded 271 times
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Problem with setting application folder

Hi,

I took a look on your .AIP but I'm afraid I don't fully understand your scenario. Can you please give us more details about what you are trying to achieve?

As a side note, in your PARENT_FOLDER which is a property based one you have a file removal operation on a file(a similar file as the one from APPDIR) at install time. Also, your body of the Execute inline custom action should be something like:
Session.Property("PARENT_FOLDER") = Left(Session.Property("MY_FILE"), InStrRev(Session.Property("MY_FILE"), "\")-1)

Does your search return a valid value? Does it return the path of your searched file?

Also you should add this custom action on the Install Execution Stage after the Searches stage. You can also take a look on the How do I debug a .VBS custom action article.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
d.caddell
Posts: 6
Joined: Tue Mar 12, 2013 3:51 pm

Re: Problem with setting application folder

Essentially I am looking to patch some files on a previous install. I am having to do this manually because I want the patch to replace some files and the install path may be different for each user. I want them to be able to perform this without having the original disk on hand and I did not set the "Do not delete extracted MSI and CAB files" Parameter on the Media Bootstrapper for the original install. The original install is over 2GB and the files are unpacked in folders next to the MSI so they can run the program from disk or install it to their computer or a network location.

My goal is to find where the original install was based on looking for a unique file to get the path. Replace the old files and add some additional new files. I know this is not the ideal way but I am kinda stuck until the next major release.
d.caddell
Posts: 6
Joined: Tue Mar 12, 2013 3:51 pm

Re: Problem with setting application folder

Also it was able to find the file in the Search part. It just isn't removing the filename from the install path
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Problem with setting application folder

Hello,

Since you want to replace some files from a previos installation you can add these files into an property based folder and
enable the Always overwrite existing file option from the Operations tab of the File properties for the related files.

If this option is enabled, the file from your package will overwrite any similar file already present on the target computer.

Because you’re search is based on a file and you need to have its parent folder in order to use the path for the property-based folder you can use the predefined Execute inline script code custom action with sequence added after the Searches from the Install Execution Stage and I manage to get the folder path where that file was installed.

Code: Select all

Session.Property("PARENT_FOLDER") = Left(Session.Property("MY_FILE"), InStrRev(Session.Property("MY_FILE"), "\")-1)
where:
  • *MY_FILE is the property assigned to the file search operation in the Search page (e.g. C:\program\editor\program.exe ).
    *PARENT_FOLDER is a public property that will contain the parent folder path of the searched file (e.g. C:\program\editor).
Just make sure this custom action is added with sequence and after the Searches stage from the Install Execution Stage. I’ve tested your scenario and it worked as expected. Also I’ve attached a zip archive which contains your fixed sample.

Please let me know if that helped.

Best regards,
Dan
Attachments
LT2500D.zip
(4.57 KiB) Downloaded 265 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”