cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ChristopheOce
Level 7

copyfile failed on plateform vista !!

Hi,

I have a basic msi project who install some file and it's work well.

But on plateform vista i have an error with a function of installscript (CopyFile)

Here is it the code of the function :

//Copy file
nRetCopy = CopyFile(szPathFile, INSTALLDIR+"\\"+LicenseName);

//If != 0 there is an error of copy file
if (nRetCopy != 0) then

switch (nRetCopy)
case 0:
MessageBox ("Files successfully copied.", INFORMATION);
case COPY_ERR_CREATEDIR:
MessageBox ("A target directory could not be created.", SEVERE);
case COPY_ERR_MEMORY:
MessageBox ("Insufficient memory.", SEVERE);
case COPY_ERR_NODISKSPACE:
MessageBox ("Insufficint disk space.", SEVERE);
case COPY_ERR_OPENINPUT:
MessageBox ("Unable to open the input files", SEVERE);
case COPY_ERR_OPENOUTPUT:
MessageBox ("Unable to copy the source files.", SEVERE);
case COPY_ERR_TARGETREADONLY:
MessageBox ("A target file already exists and cannot be overwritten.", SEVERE);
default:
MessageBox ("An unspecified error occurred.", SEVERE);
endswitch;

endif;
end;



A custom action type installscript call this function with these parameters :

return processing : asynchronous (wait for exit code)
in script excecution : deferred execution
install exec sequence : after installinitialize
condition : NOT Installed

When the program run the message is an unspecified error occured !
I choose the file with a browse dialog from the c:\ drive and i must to copy it on INSTALLDIR property !

That's works perfectly on win xp, win 2003 but on vista that s failed !

Is there someting to do for execute CA on vista !?
Thanks for your idea !
Christophe
Labels (1)
0 Kudos
(2) Replies
RobertDickau
Flexera Alumni

You might try passing the error code from CopyFile to the FormatMessage function to get a system error message, which might have more information.

A couple of things to check: Does INSTALLDIR have the correct value at that point? Does the action work if you change the action to "Deferred in System Context"?

(And a general tip: in InstallScript, the ^ operator acts like the + operator, but adds backslashes between the pieces if there isn't already a backslash. You can then replace:

INSTALLDIR + "\\" + filename

with:

INSTALLDIR ^ filename

and get a bit of protection from existing trailing backslashes...)
0 Kudos
RobertDickau
Flexera Alumni

P.S. To avoid a custom action, you might see if the MSI MoveFile or DuplicateFile table (visible in the Direct Editor view) will do what you want...
0 Kudos