WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: keslaa on March 06, 2018, 08:49:47 AM

Title: aFileCopy and Locked Files
Post by: keslaa on March 06, 2018, 08:49:47 AM
I have a script I am testing to backup user data to a network drive. It works fine but if it comes across a file that is locked or in use a prompt is shown to the user asking what they would like to do. At that point I can select "Do this for all current items" and click on "SKIP" and the script finishes just fine. In trying to find a way to completely automate this, I want to find a way that can skip these files after writing the name and directory in a log file so the user or Help Desk person can take care of these if needed. I am using aFileCopy and looked at the flags, but didn't see any that might do what I am looking for. I also looked at listing all files in a directory and then run the "If FileExist(BlaBlah) == 2" check, but there are sometimes tens of thousands of files to parse through and am not sure about the CPU cost for such a thing. This is an example of the code for the file copy:


flags = 0
src = "C:\Users\%BackupName%\Desktop\*.*"
targ = "\\<server>\<share name>\%BackupName%\Desktop")
aFileCopy(src,targ,flags)


Any ideas? Thanks!
Title: Re: aFileCopy and Locked Files
Post by: td on March 06, 2018, 11:14:49 AM
FileExist only checks for read and read sharing permissions.  It does not check for write and write sharing permissions.  This means that it may not tell you when a destination file already exists and you don't have write permissions on the destination file.  But this may not be an issue for you.

Other than that you may want to consider combining the FOF_SILENT and FOF_NOERRORUI options in aFileCopy's flags parameter ( 4|1024).  It may or may not prevent the dialog from displaying.  Of course, even if it did, you still wouldn't have a list of uncopied files.   That would require additional processing.
Title: Re: aFileCopy and Locked Files
Post by: keslaa on March 09, 2018, 05:38:44 AM
Decided to simplify it for the user and have it close out applications before executing the file copy. Thanks!