Jump to content

Recommended Posts

Posted

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

  • Moderators
Posted

@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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

$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?

  • Moderators
Posted

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

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

@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!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...