Sign in to follow this  
Followers 0
dolphins

FileCopy -> c:\program files

6 posts in this topic

Hi,

i am having issues with FileCopy and as destination a subdirectory in "c:\program files". The program that is doing the FileCopy is running with "requireAdministrator" and the UAC dialog at the program start got a "Yes".

Should work, right? I just want to make sure that FileCopy is able to do that i general. Or can't FileCopy do that since there might come up another UAC dialog and FileCopy doesn't support this? Is this case: What other chance do I have to copy files to a subdirectory in "c:\program\files"?

Regards
Dolphins

Share this post


Link to post
Share on other sites

@dolphins yes you should be able to filecopy into a sub directory of C:\Program Files. If you would like more assistance, as I mentioned in your other thread, you need to provide more info. Posting your code would be a good start.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

$fromFile = "c:\AutoUpdate\*.*"
$toFile   = '"' & "c:\program files\mycompany\mysubdir" & '"'
$retCode2 = FileCopy($fromFile, $toFile, 1)

And $retCode2 is 0 (false).

In c:\autoupdate are about 70 files and about 50 of them exist in c:\program files\mycompany\mysubdir and need to be overwritten.
The program that is doing the FileCopy is in c:\autoupdate. Maybe that is the issue? But I think FileCopy should just read the source files and if one of the source files is currently executing it should not be a problem, right?

Share this post


Link to post
Share on other sites

This works just fine for me:

#include <File.au3>

$sSource = "C:\AutoUpdate\"
$sDest = "C:\Program Files\mycompany\mysubdir\"

Local $aFiles = _FileListToArray($sSource, "*", $FLTA_FILES, True)
    For $i = 1 To $aFiles[0]
        $aTemp = StringSplit($aFiles[$i], "\")
        FileCopy($aFiles[$i], $sDest & "\" & $aTemp[$aTemp[0]])
    Next

 

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

@JLogan3o13

Thanks, that was helpful. I just made two small changes to the code. I added the overwrite parameter to FileCopy and I removed the "\" from the field $sDest (else there would be a double "\\" in the middle of the destination filename.

Thanks a lot!

Share this post


Link to post
Share on other sites

Glad you were able to get it working :)


√-1 2^3 ∑ π, and it was delicious!

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