Jump to content

FileCopy -> c:\program files


Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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

Link to comment
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?

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

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