Announcement

Collapse
No announcement yet.

Install same file to multiple locations

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Install same file to multiple locations

    Hi folks,

    I need to install the same source file into two locations on the customer system.

    I know that I can install it once and then "file.copy" it across to the other location but I wondered if there was another way of doing this. If I use the "file.copy" method then I have to remember to add an additional entry to the uninstall commands - which is doable but is more work (and at some point I will probably forget it).

    The more automated I can make this the better, because the number of locations will probably increase.

    Cheers,
    Dave

  • #2
    I would create a new function, and name it similar to File.Duplicate(). This function would take two parameters, the source and the copy's path: File.Duplicate(sSourcePath, sDuplicatePath).

    The function itself could be quite simple, just with two tasks:

    1) create the copy/duplicate of the original file;
    2) make the uninstaller aware of the additional file to be removed.

    Here is a sample:
    Code:
    [COLOR="#0000FF"]function[/COLOR] File[COLOR="#FF0000"].[/COLOR]Duplicate(sSourcePath[COLOR="#FF0000"],[/COLOR] sDuplicatePath)
      [COLOR="#0000FF"]local[/COLOR] tFileData [COLOR="#FF0000"]=[/COLOR] [COLOR="#FF0000"]{};[/COLOR]
      
      [COLOR="#008000"]-- perform copy  [/COLOR]
      File[COLOR="#FF0000"].[/COLOR]Copy(sSourcePath[COLOR="#FF0000"],[/COLOR] sDuplicatePath[COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]false[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]true[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]false[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#0000FF"]true[/COLOR])[COLOR="#FF0000"];[/COLOR]
      
      [COLOR="#008000"]-- add duplicate to list of files to be uninstalled[/COLOR]
      tFileData[COLOR="#FF0000"].[/COLOR]Filename [COLOR="#FF0000"]=[/COLOR] sDuplicatePath[COLOR="#FF0000"];[/COLOR]
      tFileData[COLOR="#FF0000"].[/COLOR]DecrementUsageCount [COLOR="#FF0000"]=[/COLOR] [COLOR="#0000FF"]false[/COLOR][COLOR="#FF0000"];[/COLOR]
      tFileData[COLOR="#FF0000"].[/COLOR]UnregisterCOM [COLOR="#FF0000"]=[/COLOR] [COLOR="#0000FF"]false[/COLOR][COLOR="#FF0000"];[/COLOR]
      tFileData[COLOR="#FF0000"].[/COLOR]UnregisterFont [COLOR="#FF0000"]=[/COLOR] [COLOR="#0000FF"]false[/COLOR][COLOR="#FF0000"];[/COLOR]
      tFileData[COLOR="#FF0000"].[/COLOR]FontDesc [COLOR="#FF0000"]=[/COLOR] [COLOR="#800080"]""[/COLOR][COLOR="#FF0000"];[/COLOR]
      tFileData[COLOR="#FF0000"].[/COLOR]BackupFile [COLOR="#FF0000"]=[/COLOR] [COLOR="#800080"]""[/COLOR][COLOR="#FF0000"];[/COLOR]
      UninstallData[COLOR="#FF0000"].[/COLOR]AddItem(UNINDATA_FILES[COLOR="#FF0000"],[/COLOR] tFileData)[COLOR="#FF0000"];[/COLOR]
    [COLOR="#0000FF"]end[/COLOR]
    
    File[COLOR="#FF0000"].[/COLOR]Duplicate(SessionVar[COLOR="#FF0000"].[/COLOR]Expand([COLOR="#800080"]"%AppFolder%[COLOR="#800080"]\\[/COLOR]MyFile.exe"[/COLOR])[COLOR="#FF0000"],[/COLOR] SessionVar[COLOR="#FF0000"].[/COLOR]Expand([COLOR="#800080"]"%ApplicationDataFolderCommon%[COLOR="#800080"]\\[/COLOR]%CompanyName%[COLOR="#800080"]\\[/COLOR]MyFileCopy.exe"[/COLOR]))[COLOR="#FF0000"];[/COLOR]
    Once the function was defined (e.g. placed into Global Functions), you could use it like File.Copy(), but both files would be removed during uninstall. You can tweak this as needed or desired.

    Ulrich

    Comment


    • #3
      Hi Ulrich,
      Many thanks for that. Using a function makes sure that the uninstall data (and anything else in the future) is automatically catered for.
      Cheers,
      Dave

      Comment

      Working...
      X