cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
georgiy_senenko
Level 5

Files cannot be copied from network drive in BasicMSI

Hello,

My installation package should copy configuration files from some specific location to another. In my basic MSI I call XCopyFile function which works pretty good if installer and configuration files are located on the local hard drive. But files are not copied if installer and configuration files are located on the mapped network drive. The piece of script is presented below

#define CONFIG_DIR "Config"
nBuffer = MAX_PATH;
if (MsiGetProperty(hMSI, "CustomActionData", szLine, nBuffer) == ERROR_SUCCESS) then;
listID = ListCreate(STRINGLIST);
if (StrGetTokens (listID, szLine, ";") > 0) then;
// Report the error.
MessageBox ("StrGetTokens failed.", SEVERE);
else
nResult = ListGetFirstString (listID, RootFolder);
nResult = ListGetNextString (listID, InstallDir);
nResult = ListGetNextString (listID, SourceDir);
endif;

ListDestroy (listID);
endif;
nResult = XCopyFile(SourceDir ^ CONFIG_DIR ^ "*.*", InstallDir ^ CONFIG_DIR ^ "*.*", COMP_NORMAL);

RootFolder, InstallDir, SourceDir values are taken correctly. I checked that by calling MessageBox. My major suspect that copying failed because installer runs under system account, which cannot access domain network drive.

Could you please advise me how it can be fixed?

Thank you in advance.

Cheers, Georgiy
Labels (1)
0 Kudos
(4) Replies
Reureu
Level 10

You are right: the system account does not know about your mapped network drive.
You could try the following solutions:
[LIST=1]
  • Use the full UNC path instead of the mapped network drive path. I don't know if that works with XCopyFile, but it might be worth a try.
  • Launch a command prompt as administrator, and use the "net" command to map your network drive. Then launch your setup from the command prompt.

    If the 2nd approach works, the you could try to call this "net" command in a custom action.

    A part from that, I would avoid copying files with XCopyFile in a custom action, because it means your setup will copy files that are not in your "File" table.
    It sounds like something which goes against best practices, in my opinion.

    • You need to take care of deleting the file(s) when deinstalling or upgrading.
    • You need to implement a rollback action.
    • The file(s) you copy won't be taken into account in the disk space cost.
    • How can you associate the file(s) with a component or with a feature?

    What do you think?
  • 0 Kudos
    georgiy_senenko
    Level 5

    Thank you for advises but unfortunately none of them worked, and files from Config directory have not been copied to destination directory.

    Probably my approach is not the best, but I don't any better idea how to copy extra configuration files which are specific for every single installation.
    Could you please tell whether you have any idea how I can manage to copy extra files if they exist?

    Regards, Georgiy
    0 Kudos
    Reureu
    Level 10

    Well, are these files totally different? Or are they all very similar for each target machine?
    Could you pack them all in the installation package, identify which target machine it is, and install one or the other lot of configuration files? You could use component conditions for that.

    Alternatively, If these config files only differ by a few lines, you might be able to install one "generic" config file, and use either the "INI File Changes", the "XML File Changes" or the "Text File Changes" to configure it for the target PC.

    Another alternative would consist of considering this configuration step separately from the installation.

    • Your installation package would only install the application, without these configuration files.
    • Then on first use, your application would not find these configuration files, and copy them from your network drive.
    • You might have to move these configuration files to the "CommonAppData" or "AppData" folder of your target PC, instead of copying them in the application folder, unless your application is running as Administrator every time.


    How does that sound?
    0 Kudos
    georgiy_senenko
    Level 5

    Yes, files might differ per installation hence they we probably provide different installation packages.
    Here we decided to resolve this problem just by calling .bat file which will copy all necessary file if needed.

    Thank you for your help and advices.

    Cheers, Georgiy
    0 Kudos