How to force a Google Drive sync from windows 7 command prompt

I am using google drive to sync personal documents when I am at work and need to update a file at home quickly for personal purposes. I have tasks at home running under task manager, which uses these updated files and sometimes they are time sensitive.

So, I need to set up something, which will force a sync on my home computer's google drive folder, before starting the scheduled task and get the latest updates I made on that file, while I am at work.

So far, all my searching points to pausing and restarting the google drive from the tray icon, in order to force a sync, short of shutting it down and restarting it. I tried and found this scheme to be working, but there is no way to replicate the same function from the command line, i.e., there is no such command line switch as:

googledrivesync.exe /pause 

or

googledrivesync.exe /restart

I tried to set up an autohotkey job to do this mouse pointing and clicking job, but due to the inconsistent number of tray icon's it is a hit and miss at best case.

I also tried to kill the googledrivesync.exe using taskkill and restarting it, but, after the run of googledrivesync.exe runs, it leaves a DOS box on the desktop open. And if this is done few more times (and it gets done as my home computer job runs every 15 minutes) the number of these windows, obstruct the running of my scheduled task due to covering the whole screen.

Any other ideas or undocumented google drive features are greatly appreciated.


Solution 1:

Since you already have a method to end the service, and the only problem is the stub cmd window, just write a little batch script that would:

  1. Execute your method to restart the service
  2. Make the shell to die.

Something like this:

taskkill /fi "Service eq Google Sync"
exit

Solution 2:

  1. Kill process GoogleDriveSync
  2. In Command Prompt go to folder, c:\program files\Google\drive\
  3. execute googledrivesync.exe /autostart

Solution 3:

This is an old question. But since this showed up when I was searching for the same problem. Here is what I did.

A small C# app that should do what OP would like for 'googledrivesync.exe /restart'

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace StartStopGDrive
{
  class Program
  {
    static void Main(string[] args)
    { 
      Process[] procs = Process.GetProcesses();
      foreach (Process proc in procs)
      {
        if (proc.ProcessName == "googledrivesync")
          proc.Kill();
      }
      Process.Start(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Google Drive\Google Drive");
    }
  }
}

Solution 4:

I dont knw if i am late but this is what I am using since last 3 to 4 years to backup my data to gdrive. I just click an icon of batch file I have created and below line is part of it. This will start google drive from within a batch file. Hope this helps.

c:> Start C:\Progra~1\Google\Drive\google~1.exe

using start command wont leave black dos box open :-)

To terminate the google drive

you can use command from dos prompt

taskkill /f /im googledrivesync.exe

hope this helps.

Apoorva