RooperGee Posted June 5, 2018 Share Posted June 5, 2018 (edited) I have a script that populates an array with the paths to certain files on a CD disc and their intended destinations. I do a simple For-Next loop to go through the array and perform a filecopy command to copy them to a location on the hard drive. My issue is sometimes CDs are bad and if I try to FileCopy a file that can't be read my script just hangs as it forever tries to access the file on the CD drive. Any suggestions on how to have a timeout if the filecopy operation is taking too long? ...the important bit: For $i = 1 to $aFiles[0][0] filecopy($aFiles[$i][0], $aFiles[$i][1]) Next Thanks! Edited June 5, 2018 by RooperGee Progress lies not in enhancing what is, but in advancing towards what will be. - Kahlil Gibran Link to comment Share on other sites More sharing options...
xcaliber13 Posted June 5, 2018 Share Posted June 5, 2018 RooperGee, I would try putting in a FileOpen first. Something like this: For $i = 1 to $aFiles[0][0] Local $hFileOpen = FileOpen($aFiles[$i][0], $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file." 10) Else filecopy($aFiles[$i][0], $aFiles[$i][1]) EndIf Next I have not tested this but might get you going in the right direction. Also put a FileClose in there. Link to comment Share on other sites More sharing options...
RooperGee Posted June 5, 2018 Author Share Posted June 5, 2018 (edited) Thanks for the suggestion xcaliber13! I tried it out and the script still just hangs while Windows tries to access the bad file on the CD rom drive. Edited June 5, 2018 by RooperGee Progress lies not in enhancing what is, but in advancing towards what will be. - Kahlil Gibran Link to comment Share on other sites More sharing options...
Earthshine Posted June 5, 2018 Share Posted June 5, 2018 (edited) Unfortunately non-production home burn CDs don't last forever. I also wonder why you want to copy things from such a slow medium. I do have an idea though, you could write a separate script that monitors those events to see what's going on and manage it that way Edited June 5, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
RooperGee Posted June 5, 2018 Author Share Posted June 5, 2018 Hello Earthshine - CDs are still used a lot in medical imaging for patients to bring their radiology exams to their doctors or hospital visits. I write a lot of code manipulating medical image data and I recently was working on a better method for importing CD data into our server repositories. I'm looking to be able to recover from scenarios where we can only read part of the CDs because some of the data is bad. I had considered writing and compiling a bit of code to just start the copy attempt and then I could monitor my own copy process to see if it has froze and then I could ProcessClose it, flag it as an error and move on to the next one. I was just hoping for a way to do it all in one script. Earthshine 1 Progress lies not in enhancing what is, but in advancing towards what will be. - Kahlil Gibran Link to comment Share on other sites More sharing options...
Earthshine Posted June 5, 2018 Share Posted June 5, 2018 yeah. sorry My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now