Scheduling a bat file which uses rclone

Cannot seem to run a mount command in a .BAT file using windows schduler or NSSM

rclone version 1.52.2

OS Windows 10 (64 bit)

cloud storage system - Google Drive

Command:

   cd "C:\Portable Apps\rclone"
   rclone mount Test: X:

I saved this above command as .BAT file and try to use it in windows scheduler, but doesnt work.

Tried NSSM too even that did not work.

Tried using a .EXE wrapper using a program called "bat2exe", even that did not work.

What did I do wrong?

any help would be appreciated.

hello and welcome to the forum,

i can help you.

can you explain what you mean, what exactly does not work?

first thing is to make sure that the .bat file works via the command line.

Does nothing....if I execute the batch file manually..everything works fine..but using task scheduler it just seems to do nothing

  • use task manager, see if rclone is running and look to see what the command line is.

  • you need to use a log file to understand what is going on.
    noticed that my command uses a flags
    --log-file
    and
    --log-level

When I type in rclone mount Test: X: --log-file=C:\Portable Apps\rclone\logs --log level=DEBUG using elevated cmd, it gives me error saying:

    Command mount needs 2 arguments maximum: you provided 3 non flag arguments: ["Test:" "X:" "Apps\\rclone\\logs\\rclonemount.txt"]

I am sorry I am very new to this.

I SOLVED IT

Made a batch file with following:

cd "C:\Portable Apps\rclone"

rclone mount Test: X: --config C:\Users\MyUsername\.config\rclone\rclone.conf

Then I entered the following settings in windows scheduler:

Executed it and Behold it worked :))

but bro i still could not understand how to get that log file, i might need it in future so please tell me how to create a log file.

  • when you run rclone, by default, it looks for the config file:
    first, in the current folder running is running
    second, rclone will look at C:\Users\username\.config\rclone\rclone.conf
    when you run a program as system user, that is a different user name and a different user profile.
    so use full paths.

  • you seem to be using spaces characters for paths, something that always leads to problems.
    if you are going to use those scary space characters in path, you must quote them like so
    --log-file="C:\Portable Apps\rclone\logs"
    https://rclone.org/docs/#windows

  • task scheduler, for the configure for, you should use
    image

  • i see that you are using portable apps.
    but if the rclone.conf file is not in the same folder as rclone.exe, then that would not be a portable app.

Hey bro the scheduling part workes like a charm using the same settings as the screenshot i gave above, but i cannot generate a log file.....sometimes its saying

--log-file not recognised as a valid flag

sometimes it says

    Command mount needs 2 arguments maximum: you provided 3 non flag arguments: ["Test:" "X:" "Apps\\rclone\\logs\\rclonemount.txt"]

it even happenes when i use double quotes or just use the path to default .conf file.

post your command, and i will take a look at it.

When i type this:

rclone mount Test: X: --log-file=C:\Portable Apps\rclone\logs --log level=DEBUG

it says:

2020/07/27 15:39:52 Fatal error: unknown flag: --log

That should be --log-level

Entering this command:

rclone mount Test: X: --log-file=C:\Portable Apps\rclone\logs --log-level=DEBUG

Gives the following error:

Command mount needs 2 arguments maximum: you provided 3 non flag arguments: ["Test:" "X:" "Apps\\rclone\\logs"]

if logs a folder or a file? you need specify a file

so try
rclone mount Test: X: --log-file="C:\Portable Apps\rclone\logs" --log-level=DEBUG

1 Like

ok bro this time the log file got saved...but the actual drive did not mount, here are the logs:

2020/07/27 23:41:45 DEBUG : rclone: Version "v1.52.2" starting with parameters ["rclone" "mount" "Test:" "X:" "--log-file=C:\\Portable Apps\\rclone\\logs\\rclonemount.txt" "--log-level=DEBUG"]

2020/07/27 23:41:45 DEBUG : Using config file from "C:\Users\Vicky\.config\rclone\rclone.conf"
2020/07/27 23:41:45 DEBUG : Google drive root '': Mounting on "X:"
2020/07/27 23:41:45 DEBUG : Adding path "vfs/forget" to remote control registry
2020/07/27 23:41:45 DEBUG : Adding path "vfs/refresh" to remote control registry
2020/07/27 23:41:45 DEBUG : Adding path "vfs/poll-interval" to remote control registry
2020/07/27 23:41:45 DEBUG : Google drive root '': Mounting with options: ["-o" "fsname=Test:" "-o" "subtype=rclone" "-o" "max_readahead=131072" "-o" "attr_timeout=1" "-o" "atomic_o_trunc" "-o" "uid=-1" "-o" "gid=-1" "--FileSystemName=rclone" "-o" "volname=Test"]
2020/07/27 23:41:45 DEBUG : Google drive root '': Init:
2020/07/27 23:41:45 DEBUG : Google drive root '': >Init:
2020/07/27 23:41:45 DEBUG : /: Statfs:
2020/07/27 23:41:46 DEBUG : /: >Statfs: stat={Bsize:4096 Frsize:4096 Blocks:3932160 Bfree:3932159 Bavail:3932159 Files:1000000000 Ffree:1000000000 Favail:0 Fsid:0 Flag:0 Namemax:255}, errc=0
2020/07/27 23:41:46 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2020/07/27 23:41:46 DEBUG : /: >Getattr: errc=0
2020/07/27 23:41:46 DEBUG : /: Readlink:
2020/07/27 23:41:46 DEBUG : /: >Readlink: linkPath="", errc=-40
The service rclone has been started.
2020/07/27 23:41:46 DEBUG : /: Statfs:
2020/07/27 23:41:46 DEBUG : /: >Statfs: stat={Bsize:4096 Frsize:4096 Blocks:3932160 Bfree:3932159 Bavail:3932159 Files:1000000000 Ffree:1000000000 Favail:0 Fsid:0 Flag:0 Namemax:255}, errc=0
2020/07/27 23:41:46 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2020/07/27 23:41:46 DEBUG : /: >Getattr: errc=0
2020/07/27 23:41:46 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2020/07/27 23:41:46 DEBUG : /: >Getattr: errc=0
2020/07/27 23:41:46 DEBUG : /: Opendir:
2020/07/27 23:41:46 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2020/07/27 23:41:46 DEBUG : /: >OpenFile: fd=/ (r), err=
2020/07/27 23:41:46 DEBUG : /: >Opendir: errc=0, fh=0x0
2020/07/27 23:41:46 DEBUG : /: Releasedir: fh=0x0
2020/07/27 23:41:46 DEBUG : /: >Releasedir: errc=0
2020/07/27 23:41:46 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2020/07/27 23:41:46 DEBUG : /: >Getattr: errc=0
2020/07/27 23:41:46 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2020/07/27 23:41:46 DEBUG : /: >Getattr: errc=0
2020/07/27 23:41:46 DEBUG : /: Opendir:
2020/07/27 23:41:46 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2020/07/27 23:41:46 DEBUG : /: >OpenFile: fd=/ (r), err=
2020/07/27 23:41:46 DEBUG : /: >Opendir: errc=0, fh=0x0
2020/07/27 23:41:46 DEBUG : /: Releasedir: fh=0x0
2020/07/27 23:41:46 DEBUG : /: >Releasedir: errc=0
2020/07/27 23:41:46 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2020/07/27 23:41:46 DEBUG : /: >Getattr: errc=0
2020/07/27 23:41:46 DEBUG : /: Getattr: fh=0xFFFFFFFFFFFFFFFF
2020/07/27 23:41:46 DEBUG : /: >Getattr: errc=0
2020/07/27 23:41:46 DEBUG : /: Opendir:
2020/07/27 23:41:46 DEBUG : /: OpenFile: flags=O_RDONLY, perm=-rwxrwxrwx
2020/07/27 23:41:46 DEBUG : /: >OpenFile: fd=/ (r), err=
2020/07/27 23:41:46 DEBUG : /: >Opendir: errc=0, fh=0x0
2020/07/27 23:41:46 DEBUG : /: Releasedir: fh=0x0
2020/07/27 23:41:46 DEBUG : /: >Releasedir: errc=0

based on the logs, looks like the mount is working.

windows 10 can be very finicky about rclone mounts.
for each user, windows maintains two list of mounts and network shares.
one list for the user Vicky with standard permissions.
one list for the user Vicky with admin permissions.
if this is the case, i can share two workarounds.

but first, let's see if this is the problem
open two command prompts, once without admin rights, one with admin rights.
you can tell the difference by looking at the title

image

image

for each command prompt, do a dir x:

1 Like

the Admin cmd shows this:

what does the non-admin command prompt show?