Sign in to follow this  
Followers 0
emmanuel

FileCopy is messing with me!

6 posts in this topic

this filecopy is always returning 0 and I can't figure out why.

I've got a dircreate that ensures the target exists, I've got error checking on the filecopy, and I've been staring at the filecopy help entry for entirely too long trying to figure this out...

Anyone have any ideas?

$stitle = "PSE DealTracker Install"
$sproduct = "PSE DealTracker"
$sSF = "\\spsefil1\comtr\Mid Office\Tools\11 - Deal Tracker\PSEDealTracker\*.*"
$stf = @ProgramFilesDir & "\PSEDealTracker"

Do
   $iFCT = FileCopy('"' & $sSF & '"', '"' & $sTF & '\*.*"', 1)
   Sleep(500)
   If $iFCT = 0 Then 
      If MsgBox(5, $stitle, 'Error copying ' & $sSF & ' to ' & $sTF & @LF & _
            "Click Retry to try again, you may need to make sure that no files in " & $sTF & _
            " are in use.  Click cancel to exit") = 2 Then
         Exit
      EndIf
   EndIf
Until $iFCT = 1

Complete code attached.

Install_PSE_Deal_Tracker.txt


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites



For a start, FileCopy handles spaces in filenames OK so you shouldn't need all those quotes. Removing those should make things easier. Also throw in a MsgBox to output the source and dest pre-copy and make sure they are correct.

Share this post


Link to post
Share on other sites

I think someone mentioned a bug in the documentation--but I thought it was fixed: FileCopy does not support wild cards in its destination parameter; it only supports them in the source.

$iFCT = FileCopy('"' & $sSF & '"', '"' & $sTF & '\"', 1)


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

For a start, FileCopy handles spaces in filenames OK so you shouldn't need all those quotes.  Removing those should make things easier.  Also throw in a MsgBox to output the source and dest pre-copy and make sure they are correct.

<{POST_SNAPBACK}>

tried those, I actually have fileexists clauses for the source and a dircreate for the target... I'll try taking off the quotes, they were part of trying to fix it. .... ... ..

:lol::ph34r: that did it.

Thanks Jon! You're tha man :(


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

One more related question, does the overwrite flag on filecopy overwrite readonly files? I seem to get the error back when there's a readonly file that's to be overwritten in the target dir...


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

One more related question, does the overwrite flag on filecopy overwrite readonly files?  I seem to get the error back when there's a readonly file that's to be overwritten in the target dir...

<{POST_SNAPBACK}>

And to answer my own question, no, filecopy's overwrite option does not overwrite RO files. I've added a filesetattrib -rsh before the filecopy and now it works.

Sounds more like a bug than a feature, when I tell something to overwrite, I mean it...

Don't you?


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0