SnakeDoc
SnakeDoc

Reputation: 14371

DirCopy() Not Working

I'm working in AutoIT to script a basic task I'll have to repeat on 50ish workstations.

I need to copy a directory and it's subdirectories and files (recursively) to a network share as a backup. For some reason, DirCopy() does not work at all.

I've tried running it on several different directories (thinking permissions issue, I'm Domain Admin account), tried doing a RunAs (again thinking permissions), and also put the #RequireAdmin tag to force the program to run on an elevated account. Nothing has worked. I can't even get it to copy empty directories.

DirCopy(@DesktopDir & "\SAMPLE\TEST1", @DesktopDir & "\SAMPLE\TEST2", 0)

Please advise!

Upvotes: 2

Views: 3198

Answers (1)

SnakeDoc
SnakeDoc

Reputation: 14371

Just figured this one out.

Turns out DirCopy() is a pretty stupid function that cannot handle if the destination directory already exists (it wants to create it for you). So if you kill the destination directory, then run the above code line, all woks as expected. But then if you add a new file into the source directory (TEST1 in my example), then it breaks again and does nothing.

Go figure...

Now time to find a work-around using something like xcopy...

Upvotes: 2

Related Questions