Shadow Copy

Started by seckner, March 01, 2014, 06:41:44 PM

Previous topic - Next topic

seckner

Sorry to ask so many questions today - quiet day to think about problems we are facing. Is there a way to use shadow copy with WB? We have a log type file that, on an error it emails us (canned routine in the program) and we have to log into that server, go to the directory, open the file, go to the bottom and find the order number so it can be fixed. Every time I try to get WB to copy, open, even read it into an array it errors - file open already. But, if I can find a way to copy it with Shadow Copy or something else I could automate what burns us at least a few time every weekend. I'm very, very open to suggestions.

ChuckC

Have you tried using IntControl 39?

It allows you to specify the file sharing mode that will be used when many of the WIL functions are used that involve opening files for read access.  In many cases, this will resolve the access conflict that prevents you from opening the file for read access while another process has the file open for write access.  However, if the process that is writing to the file has specified exclusive access to it, then there isn't anything that you can do to "magically" force it to allow you to access it.  One quick test that can be performed is to try to open the file for read access with notepad.exe; if it is successful, then IC39 should also be able to make it so that your script can open the same file for read access while sharing access with existing writers of the file.

If IC39 doesn't work, then your question about Shadow Copy pretty much brings you to the only alternative, which is to try to read from a shadow copy of the file that definitely will not be held open for an incompatible form of access.  The main issue with shadow copies is that you don't make a shadow copy of just a single file.  Instead, a shadow copy snapshot of the entire volume is made at scheduled time intervals, and based on certain tuning parameters, the oldest shadow copies of the volume get deleted when new ones are made.  Anyway, once a shadow copy of an entire volume has been made, it can actually be mounted as another volume that has read-only access.

For those who don't know, the Shadow Copy feature in current versions of Windows is really just a more general purpose from of the older "Restore Point" feature that was only applicable to the boot volume where Windows is installed at.  It allows any volume to be "rolled back" to a previous Shadow Copy "snapshot", with all changes made since the snapshot being discarded.

td

And it's saved my bacon a time or two...
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

ChuckC

Quote from: td on March 03, 2014, 07:27:00 AM
And it's saved my bacon a time or two...

Indeed it can!

Those nasty bits of malware that were set loose late last summer which encrypt all your documents in your user profile and then demand payment of a ransom within a day or two to decrypt them or else lose them entirely can be foiled to great extent by having daily shadow copies made.  Just revert back to a shadow copy prior to the malware infection and you will at least get your documents recovered.

seckner

Chuck - Thank you! IC39 worked perfectly - I was able to open and copy into an array without a problem. I never would have thought of it.