2

I want to start the new Google Drive with Task Scheduler but its path includes the number of the version so it keeps changing. The path is currently C:\Program Files\Google\Drive File Stream\53.0.8.0\GoogleDriveFS.exe but the 53.0.8.0 part will change.

TylerH
  • 20,799
  • 66
  • 75
  • 101
MagTun
  • 5,619
  • 5
  • 63
  • 104

2 Answers2

1

In recent Google Drive application for Windows, you can run the provided script :

C:\Program Files\Google\Drive File Stream\launch.bat

It looks up the latest GoogleDriveFS.exe and runs it with the same arguments as the script.

Bruno
  • 160
  • 6
0

One possible solution is to walk through the parent folder and find the folder whose name keeps changing based on some hint: here we can bet that the first character of this folder will always be a number (if this doesn't work, another way would be to walk through each folder and find the one containing the .exe you need)

import os
import subprocess

# set the part of the path that doesn't change
staticPart1= r"C:\Program Files\Google\Drive File Stream"
staticPart2 = "GoogleDriveFS.exe"

# find the subfolder that start with a number
for folder in os.listdir(staticPart1):
    if os.path.isdir(os.path.join(parentFolder, folder)) and folder[0].isnumeric():
        pathexe = os.path.join(parentFolder, folder, staticPart2 )
# to verify if the folder is the right one, uncomment the next line
            # print(pathexe)
subprocess.check_call([pathexe])

Then in Task Scheduler, in the tab "action" of a new task set these parameters:

  • in the field "progamm" add the location of your pythonw.exe or python.exe:

    "C:\Users\USERNAME\AppData\Local\Programs\Python\Python36\pythonw.exe"

  • in the field "add arguments" add the path of your file with quote:

    "C:\Users\USERNAME\Desktop\TaskScheduler\startGoogleDriveLatestExe.pyw"

MagTun
  • 5,619
  • 5
  • 63
  • 104