Rclone conf on windows and using variable

rclone.exe lsd my-remote:

The rclone config contents with secrets removed.

type = drive
client_id = 1234567890........apps.googleusercontent.com
client_secret = 1234567890........
scope = drive
service_account_file = %my-variable%\rclone\json-rclone.json
team_drive = xxxxxxxxxxxxxxxxxxxxx
root_folder_id =
acknowledge_abuse = true
stop_on_upload_limit = true
stop_on_download_limit = true

A log from the command with the -vv flag

Failed to create file system for "my-remote:": drive: failed when making oauth client: error opening service account credentials file: open %my-variable%\rclone\json-rclone.json: Impossibile trovare il percorso specificato.

So seems rclone can't "translate" variable in correct path, but if in cmd i run
notepad %my-variable%\rclone\json-rclone.json
notepad opens correct file and i can read/write it...

how can i put my variable in a rclone.config file ?
thank you

Depends on the OS, which is why we ask for it in the template..

yes, cmd.exe will do the variable substitution on the command line, and inside a batch script.
as far as i know, rclone will do that inside the config file.

one possible workaround, to use connections strings and do the variable substitution on your own.

but i write O.S.
i think i truncate a piece of post....
here version
rclone.exe version
rclone v1.62.2

  • os/version: Microsoft Windows 11 Pro 22H2 (64 bit)
  • os/kernel: 10.0.22621.1413 Build 22621.1413.1413 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.20.2
  • go/linking: static
  • go/tags: cmount

ok, so i create a variable on script and pass that?
ok thank you

yes, something like this
rclone lsd "gdrive,service_account_file='C:\data\rclone\rr\other\gdrive.sa\it.org.json':zork"

or use rclone config create

rclone config create remote drive scope=drive root_folder_id=0AMRhAloEvItAUk9PVA service_account_file=C:\data\rclone\rr\other\gdrive.sa\it.json -vv
rclone lsd remote: -vv

or maybe https://rclone.org/commands/rclone_config_update/

another variation

::@set RCLONE_CONFIG_GDRIVESAC_SERVICE_ACCOUNT_FILE=C:\data\rclone\rr\other\gdrive.sa\it.json
  "type": "service_account",^
   "private_key": "-----BEGIN PRIVATE KEY redacted END PRIVATE KEY-----\n",^
   "client_email": "test02@redacted.iam.gserviceaccount.com",^
   "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/redacted.iam.gserviceaccount.com"}

rclone lsd GDRIVESAC: -v

big thank you...

but now i have a problem with rclone-browser...
i share rclone.conf with my pc and laptop (have 2 different account and 2 different path)
i have rclone.conf in a different folder
pc : c:\users\user1\cloud1\rclone\rclone.conf
laptop : c:\users\user2\cloud2\rclone\rclone.conf

so when i launch rclone browser, i set
work ok when i use in rclone.conf
of course on pc works but on laptop not.
now i create 2 remotes with 2 path, there is a way to setup rclone.conf with
of course on pc i add on windows
%my-variable% = c:\users\user1\cloud1\rclone
and on laptop
%my-variable% = c:\users\user2\cloud2\rclone\

if not possible , i use variable for script and keep double remote on rclone.conf
no problem
thank you again

fwiw, i never, ever, store anything of importance inside the user profile on a specific machine.

each system i run on has a c:\data and use that to store portable apps such as rclone, double commander, 7zip, keepass, autohotkey, firefox profile, etc..

with rclone, , it is c:\data\rclone and inside that is both the rclone.exe and the rclone.conf
if i have a new machine, i can simply copy the folder from from one machine to another.
nice an easy

but for some reason, if you are punished, having to use the user profile,
then create a symlink from c:\user\username\folder to c:\data\folder

here is a lightly edited example, the data is in c:\data\rclone, just where i want it.

mklink /j c:\users\user01\rclone c:\data\rclone 

dir /b C:\data\rclone\rclone.* 

dir /b C:\Users\user01\rclone\rclone.* 

dir C:\Users\user01
 Volume in drive C is EN10CDRIVE
 Volume Serial Number is 72D6-675C

 Directory of C:\Users\user01

03/29/2023  04:11 PM    <JUNCTION>     rclone [c:\data\rclone]

big thank you, i don't think to symlink.
now i try with mlink...

i'm curious. just for information.
why you use c:\data and don't use user profile?
for security?

now, i use this strategy...
i have my cloud (owncloud self-hosted) and every pc/laptop i install owncloud client, sync my files and put in variable
%my-variable% = c:\users<username><path-to-owncloud>\

so i have some script (rclone, batch, putty, winscp, ecc..) to point to
%my-variable%\software\xxxxxxxxxx.exe -arg .................

works like a charm....
of course i have password for user and bitlocker enabled...

but I never thought to use c:\data or other path/folder...

for me thread is solved, is only my curiosity...

thank you again


that approach, in some ways more secure, in some ways less secure.
you seem interested in that, so i made mention of it.

mostly about convenience, as i work on lots of new machines, that need to have multiple users setup.
so having everything in one place, is a huge bonus.
and when i am done with a machine, easy to delete.

on the downside:
if you have a portable app that use the %temp%, or %appdata%, that can be a problem.

I have been doing that setup for over 15 years now, have all the kinks worked out.
and believe me, there were kinks along the way.

ok thank you for explanation.
for now I think I will continue to use user pfofile
i change laptop and pc every two/years, so is not a big problem setup variable...

i don't have a strong security with hardware key , but only a password for "boot" and a password to login...

thank you again :slight_smile:

sure, welcome..

that makes sense, as only one machine to deal with.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.