cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Pilgrim

Copy file from CD to install directory

Hi,

I have been looking into this issue for about 4 hours and have got pretty much nowhere, it cannot be that hard surely?

All i am trying to do is copy a file from the same destination as the installer into the install directory. This needs to be done as the user manual is never ready to go when the installer is built so i am looking for a way to have the user manual on the CD and then it gets copied into the install directory after the install.

I have been attempting to do this with the MoveFile table and have set up an entry as below

FileKey : CopyUserManual
Component : UserManual
SourceName : User Manual.pdf
DestName: User Manual.pdf
SourceFolder : SOURCEDIR
DestFolder : INSTALLDIR
Options : 1

At first the installer didn't work at all as i hadn't included the component in the project. I did that and then the installer ran but the file was not copied

Does anyone have any ideas as to where i am going wrong??

Thanks in advance

Ross
Labels (1)
0 Kudos
6 Replies
Highlighted
Pilgrim

Re: Copy file from CD to install directory

So, what you want to do is add a file to the CD after your installation package is built, and copy it to a target folder during installation?

It is not impossible, but you will inevitably face quite a few limitations:
[LIST=1]
  • You cannot include a file to an MSI package before this file actually exists. Consequently, you cannot add a file to an MSI package after this package was built. You could possibly use a Transform file, but that's a different story.
  • I don't think you can change an existing file in the source folder after building the MSI package either. I think the MSI package contains quite a few checksum to make sure that the source files are intact.
  • You might also face an issue with the package size. The capacity of a CD is limited, and InstallShield will spread your files (or your cabinet file) on several CD's if the overall size of the package exceeds the size of a CD. So adding files to a CD after the package has been built is not a good idea, even if these files are just "advanced support files".


    The best way to handle this would be to build your package once all the files (including your user manual) have been produced, and adapt your development process accordingly. In other words: get your technical writers to finish their job earlier.
    If you really want to supply a user manual that can change until the last minute, you should consider uploading it to a website that your customers can access.

    However, if you are not able to adapt your development process to these good practice, here is an idea:

    • Do not create any component in your installation package for this file.
    • Now let's assume you have just copied this file to a subfolder of your CD.
    • Create a custom action that just copies this file from one subfolder of the CD to the target directory.
    • You need to create a similar action that removes this file from the target folder on uninstall.
    • Also, don't forget the rollback actions!

    This idea will not overcome problem no3 listed above, though.

    Another possibility would consist of building a patch that simply adds your user manual to your product.
    You would obviously build this patch AFTER building the main installation package.
    Push this reasoning further, and create a separate installation package for your user manual, then chain both installations.
    Any other idea? A transform file, maybe? But honestly, your life would be easier if you had all files before building your package.
  • 0 Kudos
    Highlighted
    Pilgrim

    Re: Copy file from CD to install directory

    Thanks for the reply, basically yes that is what i am attempting to do

    I was afraid that was the answer, unfortunately this is a requirement from higher up and was dumped on my desk!!! I requested a reason at the time as to why the user manual could not be produced in time to go with the release and there has been no answer!!, not really a surprise though

    Looking at my options i think the best is the custom action route, our installer is only about 200MB so there is no issue on size at all

    Thanks for the additional actions regarding uninstall as i probably would have forgotten about them

    Regards

    Ross
    0 Kudos
    Highlighted
    Pilgrim

    Just an extra idea

    In theory, you could add some items to the Component and File tables at runtime, so you could benefit from the install/uninstall/rollback mechanism. It would also allow to use the existing version check mechanism (think about the minor upgrade scenario: the files with the highest version wins).

    Not sure how that would work with file checksums, but it could be worth a try.
    0 Kudos
    Highlighted
    Pilgrim

    Re: Copy file from CD to install directory

    I have finally got around to trying this (ran out of actual work to do!!!) and have made progress

    function CopyUserManual(hMSI, destDirectory)
    NUMBER nResult;
    STRING error;
    STRING sourcePath;
    begin
    sourcePath = SourceDir;
    nResult = CopyFile(sourcePath ^ USER_MANUAL_NAME, destDirectory ^ USER_MANUAL_NAME);
    error = FormatMessage(nResult);
    end;

    There is a path set during the installation that holds the data files and the User Manual needs to go in there as well. If i put in a proper path instead of destDirectory it works fine, however i need to pass that value in from the installer. Is there a way to do this?

    Thanks
    0 Kudos
    Highlighted
    Pilgrim

    Re: Copy file from CD to install directory

    Just in case someone else is trying to do something similar, i have managed to get it to work

    function CopyUserManual(hMSI)
    STRING dataPath, error, sourcePath;
    NUMBER nvType, nvSize, nResult, nBufferSize;
    begin

    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    RegDBGetKeyValueEx("SOFTWARE\\EuroAvionics\\EasyTask", "ETGSDataPath", nvType, dataPath, nvSize);

    if (StrLengthChars(dataPath) > 0) then
    //Do Nothing
    else
    RegDBGetKeyValueEx("SOFTWARE\\Wow6432Node\\EuroAvionics\\EasyTask", "ETGSDataPath", nvType, dataPath, nvSize);
    endif;

    nBufferSize = MAX_PATH;
    MsiGetProperty(ISMSI_HANDLE, "SETUPEXEDIR", sourcePath, nBufferSize);

    nResult = CopyFile(sourcePath ^ USER_MANUAL_NAME, dataPath ^ USER_MANUAL_NAME);
    error = FormatMessage(nResult);
    end;

    Luckily we were already storing the datapath selected during the install in the registry as we need it when the program runs so i can use that as the destination. Getting the source path proved more challenging as the installer thinks it is running from a temp directory as that is where it is extracted to. In the end i found the SETUPEXEDIR which points to the actual exe location.
    0 Kudos
    Highlighted
    Pilgrim

    Re: Copy file from CD to install directory

    And did you implement rollback and uninstall custom actions?
    What about minor upgrades?
    0 Kudos