Skip to content

A way to make Rclone run in the background on Windows #5175

Open

Description

@fxzxzyra

Sorry, I don't know if this issue is repeated with others, but I don't find any relevant statements or methods in the official documents.

What is your current rclone version (output from rclone version)?

v1.55.0-beta.5343.9c9186183

What problem are you are trying to solve?

Make Rclone run in the background on Windows.

How do you think rclone should be changed to solve that?

Using VBS scripts is the viable approach I found.
For example, my VBS script is:

DIM Temp
DIM Command
DIM Path
DIM Remote_Path
Quotation=chr(34)
Temp = "D:/Rclone Temp"
Set WS = Wscript.CreateObject("Wscript.Shell")

Remote_Path = "Onedrive_Personal:/Storage/"
Path = "A:"
Command = "rclone mount " & Quotation & Remote_Path & Quotation & " " & Quotation & Path & Quotation & " --cache-dir " & Quotation & Temp & Quotation & " --transfers 16 --buffer-size 32M --vfs-cache-mode writes --volname \\Local\onedrive"
WS.Run Command, 0

It does work:
image

Activity

  1. albertony commented on Mar 28, 2021

    @albertony
    Contributor

    There was a discussion in the forum where some options are mentioned, including the VBScript approach similar to yours, see:

    Then, after that we added a command line argument --no-console, which should be available in latest version of rclone. See:

    I don't know if you have seen these? Do you think there should be more done, with regards to functionality and/or documentation?

    I have started a pull request for detailed documentation of automatic running of rclone, which includes running in background but with main focus on starting on windows startup or on schedule etc.. My attempt has sort of stranded, though, because it turned out to be difficult to find a consistent behavior accross different versions of Windows etc, and then a detailed doc like this needs to considere these differences - or be rewritten to be much less detailed. See:

  2. fxzxzyra commented on Mar 28, 2021

    @fxzxzyra
    Author

    https://rclone.org/commands/rclone_mount/
    It's mentioned: You can only run mount in foreground mode on Windows.
    So I don't know the new way.

  3. albertony commented on Mar 28, 2021

    @albertony
    Contributor

    I see, that can be a bit confusing. But that sentence is related to the --daemon flag and internals of the mount command (don't know enough of the details myself). The --no-console flag, and the other "third party" methods discussed in the forum thread, are unrelated to this, as these will just hide the console window that rclone creates, while doing nothing with how the process itself runs (which I think the --deamon option does).

  4. fxzxzyra commented on Mar 28, 2021

    @fxzxzyra
    Author

    OK, I see. Although VBS scripts are also useful, Rclone itself can solve this problem better. Or you can use VBS as a common method for all Windows versions (I don't know about it, and I don't know if it's possible 🤣).

  5. ivandeex commented on Mar 28, 2021

    @ivandeex
    Member

    I don't think we will ever implement --daemon flag on Windows as is, since Unix daemon semantics is too different from a Windows service.
    Currently a good solution is to use nssm. It may be partially described in rclone docs by PR #4972 when it gets merged.

    If some day we decide to embed the Windows service feature in rclone, we can probably base it on one of the following:

    I guess we will also need to use registry to keep service state and coordinate with the WinFSP manager. This will introduce a number of windows-specific command-line flags. This is not as easy as it may seem.

    Even on Linux the --daemon flag currently doesn't work with the mount command or in the --rc mode. It will be fixed by the relevant tickets (#2968, #2618).

  6. self-assigned this
    on Mar 28, 2021
  7. fxzxzyra commented on Mar 28, 2021

    @fxzxzyra
    Author

    Okay, thank you. Do I need to close this Issue? Or keep it open? I think my goal has been reached and my question has been resolved.

  8. added this to the Soon milestone on Apr 4, 2021
  9. removed their assignment
    on Dec 14, 2021
  10. MaxJahWn commented on Jul 22, 2023

    @MaxJahWn

    I‘ve configured
    powershell -Command "Start-Process -FilePath rclone -WindowStyle hidden -ArgumentList \"mount MyWebdav: Z: --network-mode {{other arguments}}\""
    in taskschd.msc, it works well.

  11. fredinj commented on Oct 19, 2023

    @fredinj

    Kinda sad that this still isn't supported by default.

    Using task scheduler is good, but unmounting is a pain, using a windows service is easier as you can just stop the service and it'll unmount properly. Setting up a regular service is almost perfect for me. But it might not be desirable if you have multiple users in your PC.

    $params = @{
      Name = "Rclone-Mount"
      BinaryPathName = "rclone-path arguements"
      DisplayName = "Rclone"
      StartupType = "Automatic"
      Description = "This is a test service."
      Credential = "DOMAIN\USER"
    }
    New-Service @params
    

    I had to run the service with user credentials or rclone wouldn't write to existing files. But this is the best workaround I've found yet, no flashing cmd either.

  12. fxzxzyra commented on Oct 19, 2023

    @fxzxzyra
    Author

    Kinda sad that this still isn't supported by default.

    Using task scheduler is good, but unmounting is a pain, using a windows service is easier as you can just stop the service and it'll unmount properly. Setting up a regular service is almost perfect for me. But it might not be desirable if you have multiple users in your PC.

    $params = @{
      Name = "Rclone-Mount"
      BinaryPathName = "rclone-path arguements"
      DisplayName = "Rclone"
      StartupType = "Automatic"
      Description = "This is a test service."
      Credential = "DOMAIN\USER"
    }
    New-Service @params
    

    I had to run the service with user credentials or rclone wouldn't write to existing files. But this is the best workaround I've found yet, no flashing cmd either.

    I’m glad you shared your method.

  13. Kein commented on Mar 26, 2024

    @Kein

    Then, after that we added a command line argument --no-console, which should be available in latest version of rclone. See:

    It does not work under Windows, it opens cmd prompt asking to run under cmd/shell

  14. albertony commented on Mar 26, 2024

    @albertony
    Contributor

    @Kein : I'm not sure if this is what you refer to, but rclone is still a console application, so even with --no-console it will in fact still need to allocate a console, only to hide it early on in the application's initialization code. Please share more details, show an example, if you meant something else or have further questions.

  15. DawnImpulse commented on May 29, 2024

    @DawnImpulse

    I have found a way to basically start any cli service in background - https://github.com/jeansaad/chalet
    Using this tool we can configure any cli command & use it in background (only caveat is you have to start it after every PC restart)

    also for a simple tray icon to start/stop services - https://github.com/macav/hotelier

  16. ANDiTKO commented on Jul 14, 2024

    @ANDiTKO

    Here is alternative solution that does not require a service, only 2 files.

    Fist you need the mount command. For that we will use a .bat file. Lets call it mount_cloud.bat Here is the sample code:

    @echo off
    rclone mount cloud: W: --vfs-cache-mode full --no-console --vfs-cache-max-size 50G --vfs-cache-max-age 24h
    

    dont forget to replace replace cloud: with your remote name, and W: with the drive letter that you want to assign to your drive.
    this will run your rclone mount command with the --no-console parameter so it won't have a console window open.

    Then we need a VBS script that will run the command for you. So the terminal window will remain hidden.
    Lets call the second file mount_rclone.vbs here is the code:

    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "C:\rclone\mount_cloud.bat" & chr(34), 0
    Set WshShell = Nothing
    

    Replace the C:\rclone\mount_cloud.bat with the correct path where you stored the previous file.
    You can also copy/paste the second line if you want to mount multiple drives at once.

    Then in Windows Task Scheduler run the mount_rclone.vbs after you logon or whenever you want this to be triggered. (I think that if you make a shortcut in startitems will work too, but I haven't tried it)
    And you can make your windows mount automatically your rclones and it will stay in the background.
    No console windows. No services. Just files.

  17. fxzxzyra commented on Jul 14, 2024

    @fxzxzyra
    Author

    Since Windows will deprecate VBS, the only way to make Rclone run in the background in the future is to use a service.

  18. jason-eu commented on Nov 14, 2024

    @jason-eu

    Here is alternative solution that does not require a service, only 2 files.

    Fist you need the mount command. For that we will use a .bat file. Lets call it mount_cloud.bat Here is the sample code:

    @echo off
    rclone mount cloud: W: --vfs-cache-mode full --no-console --vfs-cache-max-size 50G --vfs-cache-max-age 24h
    

    dont forget to replace replace cloud: with your remote name, and W: with the drive letter that you want to assign to your drive. this will run your rclone mount command with the --no-console parameter so it won't have a console window open.

    Then we need a VBS script that will run the command for you. So the terminal window will remain hidden. Lets call the second file mount_rclone.vbs here is the code:

    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "C:\rclone\mount_cloud.bat" & chr(34), 0
    Set WshShell = Nothing
    

    Replace the C:\rclone\mount_cloud.bat with the correct path where you stored the previous file. You can also copy/paste the second line if you want to mount multiple drives at once.

    Then in Windows Task Scheduler run the mount_rclone.vbs after you logon or whenever you want this to be triggered. (I think that if you make a shortcut in startitems will work too, but I haven't tried it) And you can make your windows mount automatically your rclones and it will stay in the background. No console windows. No services. Just files.

    THANK YOU !

  19. albertony commented on Nov 26, 2024

    @albertony
    Contributor

    @fxzxmic What do you think is still missing in rclone?

    As I see it, simply starting rclone with --no-console is a ready to use, super easy solution to this. The built-in support for installing rclone as a Windows service, using PowerShell's New-Service command, is almost just as easy, if you want more automated execution. This is all documentation at https://rclone.org/install/#autostart now. And in addition, classic Windows tricks with Windows/VB Script, PowerShell, or something else is well covered in rclone forum, and on the internet in general. I fail to see a need for anything more? But I may be missing some specific detail, specific use case, or something?

  20. saintech commented on Jul 1, 2025

    @saintech

    There is also this way using the scheduler:

    conhost --headless c:\rclone\rclone.exe sync c:\files remote:/files --log-file c:\rclone\logs\sync_files.txt
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions