title: Task Scheduler Not Running task with Network Path
body: <p>I am working in a test development environment and I am creating a task in task scheduler that is using a remote network location to access an executable file. Although in my scenario that network address is of my own machine.
  Like this</p>
  
  <blockquote>
    <p>\\MyComputerName\FolderOnMyPC\application.exe</p>
  </blockquote>
  
  <p>Now I have given proper sharing access to the folder and I can access the executable via Explorer but when I create a task in Task Scheduler I am unable to run it. Although the task runs fine with the local disk path like this</p>
  
  <blockquote>
    <p>D:\FolderOnMyPC\application.exe</p>
  </blockquote>
  
  <p>I have tried looking into this over the Internet but I am unable to find any workaround or the reason it is happening as I have given every possible access to the folders even in </p>
  
  <blockquote>
    <p>System32/Tasks</p>
  </blockquote>
  
  <p>There are also some arguments that are specified in the arguments section of the Task Scheduler</p>
  
  <p><strong>Edited</strong></p>
  
  <p>I am sharing the code for executing the task. </p>
  
  <pre><code>public Task&lt;int&gt; Launch(string Path, string iniFilePath)
          {
              try
              {
                  TaskService taskService = new TaskService();
  
                  const string TaskName = "LaunchTask";
                  if (taskService.FindTask(TaskName) != null)
                  {
                      var task = taskService.FindTask(TaskName);
                  }
  
                  iniFilePath = "\"" + iniFilePath + "\"";
                  string completeArgument = "/portable /skipupdate " + iniFilePath;
                  TaskDefinition taskDefinition = taskService.NewTask();            
                  taskDefinition.Principal.LogonType = TaskLogonType.S4U;
                  taskDefinition.Actions.Add(new ExecAction(mt4Path, completeArgument, null));                          
                  taskDefinition.Settings.Hidden = false;
                  Microsoft.Win32.TaskScheduler.Task mtTask = taskService.RootFolder.RegisterTaskDefinition(TaskName, taskDefinition);
                  RunningTask runningMT4 = mtTask.Run();
                  int processIdMT = (int)runningMT.EnginePID;
                  mt4Task.Folder.DeleteTask(mtTask.Name);
                  return System.Threading.Tasks.Task.FromResult(processIdMT);
              }
              catch
              {
                  throw;
              }
          }
  </code></pre>
  
  <p>Some extra information about the project is that I am working on a Service Fabric Project and its using it as its Service.</p>