Drive added by Rclone mount on a windows system could not be used while I am running my c# code as a service

I am using Rclone to mount the google drive on a windows system. The drive is successfully mounted and it can be accessed by the c# code when it is running normally as an exe. But when the same piece of code is running as a windows service it can not access the drive. I have tried several things and read out most of the forum but could not find any solution.

Command by which I am mounting:-

 rclone mount --vfs-cache-mode full gdrive:/ g:

When I run this command by command prompt or by c# code by running it as a process it works fine but the same thing fails when the same code run as a windows service.

Rclone version :-
rclone v1.59.2

  • os/version: Microsoft Windows 10 Pro 21H1 (64 bit)
  • os/kernel: 10.0.19043.2006 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.18.6
  • go/linking: static
  • go/tags: cmount

When I am running the command normally I am able to generate log file but no log file is getting created when running as a windows service. I tried login on that windows service by various accounts. I tried with local account with the Allow service to interact with desktop option checked still no luck.

I have read somewhere that when running as a service the rclone is not able to access the config file, or you need to pass the config file path in the command itself but I was unable to figure out how to do that too.

Please help I am stuck at this problem and it's very urgent.

C# code
I just pass the command mentioned above to this method. When running normally like from visual studio or by double clicking the exe generated from it everything works fine but same code when running as windows service nothing happens not even the rclone throw some error.

public static void executeProcessInCMD(string methodArguments)
                methodArguments = "\"" + methodArguments + "\"";
                Process p = new Process();
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                p.EnableRaisingEvents = true;
                startInfo.FileName = "cmd.exe";
                startInfo.UseShellExecute = false;
                startInfo.Arguments = "/c " + methodArguments;
                startInfo.RedirectStandardError = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.RedirectStandardInput = true;
                startInfo.CreateNoWindow = true;
                startInfo.Verb = "runas";
                p.StartInfo = startInfo;
                string error = p.StandardError.ReadToEnd();
                if (error != string.Empty)
                    Console.WriteLine("error in executing cmd process : "+error);
            catch (Exception ex)

There are some documentation at which may be relevant, if you haven't seen it already? And also

need to use a log file, for example,
--log-level=DEBUG --log-file=c:\path\to\log.txt

and to find that file rclone config file

and for testing, might try a simple command, for example,
rclone listremotes --log-level=DEBUG --log-file=c:\path\to\log.txt --config=c:\path\to\rclone.conf

After trying many things, I realized I needed to create a service using NSSM. When I use Nssm to create a mount the drive that is created in my system is now accessible to the c# code when running as a service.

Thank you. Creating mount using NSSM solved my problem.

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