Skip to content

Instantly share code, notes, and snippets.

@djekl
Last active November 11, 2019 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djekl/20087c254f9409f3981c4755b87e61b6 to your computer and use it in GitHub Desktop.
Save djekl/20087c254f9409f3981c4755b87e61b6 to your computer and use it in GitHub Desktop.
Setup Google Drive to be ran as a service - https://www.deskscaler.com/running-google-drive-as-a-windows-service
:: 1) Download srvany.exe from Microsoft Windows 2003 Resource Kit (available free from Microsoft).
:: http://www.microsoft.com/en-au/download/details.aspx?id=17657
:: ----------------------
:: 2) Copy srvany.exe into the folder where google drive is installed or next to this script file.
:: ----------------------
:: 3) Run this script as an Administrator
:: ----------------------
echo off
cls
SET STARTING_DIR=%CD%
SET SCRIPT_DIR=%~dp0
echo Running from: %STARTING_DIR%
echo Script Dir: %SCRIPT_DIR%
SET DEFAULT_USERNAME=%USERDOMAIN%\%USERNAME%
SET /P UNAME=Enter username for account to run service under. (%DEFAULT_USERNAME%) || SET UNAME=%DEFAULT_USERNAME%
SET /P PWORD=Enter %UNAME% password. || Set PWORD=correct-horse-battery-staple
If "%PWORD%"=="correct-horse-battery-staple" goto :sub_error_nopass
echo Copying srvany.exe to C:\Program Files\Google\Drive
copy %SCRIPT_DIR%\srvany.exe "C:\Program Files\Google\Drive"
echo Adding Google Drive as a service...
echo sc create GoogleDriveSync displayName= "Google Drive Service" start= auto obj= "%UNAME%" password= %PWORD% binPath= "C:\Program Files\Google\Drive\srvany.exe"
sc create GoogleDriveSync displayName= "Google Drive Service" start= auto obj= "%UNAME%" password= %PWORD% binPath= "C:\Program Files\Google\Drive\srvany.exe"
echo Updating registry for service...
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\GoogleDriveSync\Parameters /f
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\GoogleDriveSync\Parameters /v Application /d "C:\Program Files\Google\Drive\googledrivesync.exe" /f
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\GoogleDriveSync\Parameters /v AppParameters /d "/autostart" /f
echo Starting service...
net start GoogleDriveSync
echo Finished.
pause
goto:eof
:sub_error_nopass
echo No password given. Ending.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment