Copy From Google Drive Fails

Started by MikeInThe901, September 05, 2023, 09:02:55 AM

Previous topic - Next topic

MikeInThe901

Quicken discourages users from storing their data file on Google Drive. They prefer to run it locally then back it up to Google Drive (which in our case is mirrored in both locations) when you exit. OK, we can do that. Add to the mix that we have PC1 at office and PC2 at home. User wants to, and should be able to, run Quicken at either location (only one at a time) and use Google Drive's replication to not have to manually update the files each time he switches locations.

So the script below aims to automate this process. His name was changed in it. Script checks 2 files in diff folders to see which is newer. It copies the Google Drive file if that one is newer; otherwise it starts Quicken using the local file. Once the user exits from Quicken, it copies the local data file to My Drive, and shows the user the timestamp of the data file. From there Google Drive replicates to the My Drive cloud, and is synced with the PC at the other location. Easy Peasy, right?

My problem is that the script errors out on the first FileCopy line with a 1009 WinBatch error reading the source file. But if I change the script and copy that same file from a different, non-MyDrive folder, it works. And if I manually copy that file it works. It's almost like there's something preventing the WinBatch FileCopy command from working with My Drive.

================ WINBATCH SCRIPT BEGIN

; File comparison between production Quicken data file location and backup location.
; If local file is not the most current it copies from My Drive to ensure we always open
; the most current file in the local folder no matter which computer (home or office) we run it from.

File1=FileTimeCode("C:\users\mike\documents\quicken\mike's quicken data.qdf")
File2=FileTimeCode("C:\users\mike\my drive\mike parker\quicken backups\Mike's Quicken Data.qdf")

If File1==File2
   Stamp="File comparison shows that the Quicken files have the same timestamp. Will start Quicken with the local file."
   GoTo Run
Else
   If File1 > File2
      Stamp="File comparison shows that the local file is newer. Will start Quicken with that file."
      GoTo Run
   Else
      Stamp="File comparison shows that the MyDrive file is newer. Will copy it to the local Quicken folder, then start Quicken with that file."
      FileCopy(File2, File1, @False)
      EndIf
EndIf

:Run
;Message("", stamp)
DirChange("C:\Program Files (x86)\Quicken\")
RunWait("qw.exe","")

DirChange("C:\users\mike\documents\quicken\")
MyDrive=("C:\users\mike\my drive\mike parker\quicken backups\")
FileCopy("mike's quicken data.qdf", MyDrive, @False)
File3=FileTimeGet("C:\users\mike\my drive\mike parker\quicken backups\Mike's Quicken Data.qdf")
Message("The timestamp of the backup Quicken file on MyDrive is", File3)

================ WINBATCH SCRIPT END

Any ideas?

td

Keep in mind that I don't use Google Drive because of annoying unhandled driver exceptions. Not sure if this is more of an MSFT problem or a Google problem but given recent history I suspect MSFT.

The best approach to this or any computer problem is to use a few problem-solving skills.

In this case, the first thing to check for is a UAC problem with your script. Assuming you are logged on to a PC with an admin account try renaming your script with the file extension ".wbt_if" instead of ".wbt". If your script works after the rename, you have a UAC problem.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MikeInThe901

I used a poor choice of words. It's not a script, it has been compiled and is an exe.

td

Then what are your compiled script's UAC  settings?

<edit> It is much easier to find script problems by running the uncompiled script and only compiling once the problem is solved.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Installed Google Drive on Windows 11 virtual machine and had no issues copying files to and from a Google Drive mapped into the file system. Now I just need to remove it from the VM.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MikeInThe901

Excellent suggestion td! Now making progress debugging the script chunks on my own PC first. Thank you.

ChuckC

I routinely use Google Drive on both Windows 10 & Windows 11 with multiple drive letters mapped to several different Google accounts as a means of moving files between multiple computers on various networks that all have access to the 'Net, and it tends to work reliably for me.  The only issue I've encountered is one Windows Update applied on Windows 11 that caused the drive letters for my Google Drives to disappear until 2 or 3 reboots had been performed and a repair of the Google Drive installation was performed.

Perhaps one caveat is that if you try to move something like 1GB+ of data in lots of smaller files, the client portion of Google Drive has some kind of throttling behavior that may slow down the replication of changed files or copied/dropped files.  After some period of time passes, other computers will "see" the updated files and be able to access them.

td

Based on the OP's posted script there is another possibility to consider. The file being copied may be being opened without read-sharing enabled by another process preventing FileCopy from reading it.

The WIL FileLockItemize function can be used as a debugging tool to detect any processes holding the file open.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade