title: How to schedule azcopy on windows task schedueler?
body: <p><strong>Goal</strong>
  Syncing my virtual drive (Azure file share) to a Azure blob storage container</p>
  
  <p><strong>Solution</strong>
  For this solution i'm using azcopy. When i run azcopy with my create batch file, everyting is running correctly.</p>
  
  <p>But i also want to schedule this, like every night.
  For this i will use windows tasks scheduler.</p>
  
  <p>Windows tasks scheduler runs the bat file correctly. My bat file also creates a log file. The output in the logfile is different when i run manual vs by the task scheduler.</p>
  
  <p><strong>Batch file:</strong></p>
  
  <pre><code>@echo off
  IF EXIST C:\inetpub\wwwroot\tasks\azcopy_logs.txt (
      del C:\inetpub\wwwroot\tasks\azcopy_logs.txt
  )
  set LOGFILE=C:\inetpub\wwwroot\tasks\azcopy_logs.txt
  call :LOG &gt; %LOGFILE%
  exit /B
  
  :LOG
  
  SET source="Y:\my-folder"
  echo %source%
  SET dest=^"https://TEST.blob.core.windows.net/my-container/?sv=2019-02-02^&amp;ss=bfqt^&amp;srt=sco^&amp;sp=rwdlacup^&amp;se=2120-02-26T14:56:15Z^&amp;st=2020-02-26T06:56:10Z^&amp;spr=https^&amp;sig=TEST^"
  
  echo %dest%
  
  azcopy.exe sync %source% %dest%
  
  
  exit
  </code></pre>
  
  <p><strong>Ouput when running manual</strong></p>
  
  <pre><code>"Y:\my-folder"
  "https://TEST.blob.core.windows.net/my-container/?sv=2019-02-02&amp;ss=bfqt&amp;srt=sco&amp;sp=rwdlacup&amp;se=2120-02-26T14:56:15Z&amp;st=2020-02-26T06:56:10Z&amp;spr=https&amp;sig=TEST"
  
  Job a84acee9-1796-f44b-4852-530d052db5a0 has started
  Log file is located at: C:\Users\x\.azcopy\a84acee9-1796-f44b-4852-530d052db5a0.log
  
  
  0 Files Scanned at Source, 0 Files Scanned at Destination
  334 Files Scanned at Source, 672 Files Scanned at Destination, 2-sec Throughput (Mb/s): 0
  The source and destination are already in sync.
  </code></pre>
  
  <p><strong>Ouput running by task scheduler</strong></p>
  
  <pre><code>"Y:\my-folder"
  "https://TEST.blob.core.windows.net/my-container/?sv=2019-02-02&amp;ss=bfqt&amp;srt=sco&amp;sp=rwdlacup&amp;se=2120-02-26T14:56:15Z&amp;st=2020-02-26T06:56:10Z&amp;spr=https&amp;sig=TEST"
  
  Cannot perform sync due to error: sync must happen between source and destination of the same type, e.g. either file &lt;-&gt; file, or directory/container &lt;-&gt; directory/container
  </code></pre>
  
  <p><strong>Task scheduler xml definition</strong> </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-16"?&gt;
  &lt;Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"&gt;
    &lt;RegistrationInfo&gt;
      &lt;Date&gt;2020-02-25T13:30:25.4791113&lt;/Date&gt;
      &lt;Author&gt;my-user&lt;/Author&gt;
      &lt;URI&gt;\azcopy\my task name&lt;/URI&gt;
    &lt;/RegistrationInfo&gt;
    &lt;Triggers&gt;
      &lt;CalendarTrigger&gt;
        &lt;StartBoundary&gt;2020-02-25T13:29:16&lt;/StartBoundary&gt;
        &lt;Enabled&gt;true&lt;/Enabled&gt;
        &lt;ScheduleByDay&gt;
          &lt;DaysInterval&gt;1&lt;/DaysInterval&gt;
        &lt;/ScheduleByDay&gt;
      &lt;/CalendarTrigger&gt;
    &lt;/Triggers&gt;
    &lt;Principals&gt;
      &lt;Principal id="Author"&gt;
        &lt;UserId&gt;my-user-id&lt;/UserId&gt;
        &lt;LogonType&gt;Password&lt;/LogonType&gt;
        &lt;RunLevel&gt;LeastPrivilege&lt;/RunLevel&gt;
      &lt;/Principal&gt;
    &lt;/Principals&gt;
    &lt;Settings&gt;
      &lt;MultipleInstancesPolicy&gt;IgnoreNew&lt;/MultipleInstancesPolicy&gt;
      &lt;DisallowStartIfOnBatteries&gt;true&lt;/DisallowStartIfOnBatteries&gt;
      &lt;StopIfGoingOnBatteries&gt;true&lt;/StopIfGoingOnBatteries&gt;
      &lt;AllowHardTerminate&gt;true&lt;/AllowHardTerminate&gt;
      &lt;StartWhenAvailable&gt;true&lt;/StartWhenAvailable&gt;
      &lt;RunOnlyIfNetworkAvailable&gt;false&lt;/RunOnlyIfNetworkAvailable&gt;
      &lt;IdleSettings&gt;
        &lt;StopOnIdleEnd&gt;true&lt;/StopOnIdleEnd&gt;
        &lt;RestartOnIdle&gt;false&lt;/RestartOnIdle&gt;
      &lt;/IdleSettings&gt;
      &lt;AllowStartOnDemand&gt;true&lt;/AllowStartOnDemand&gt;
      &lt;Enabled&gt;true&lt;/Enabled&gt;
      &lt;Hidden&gt;false&lt;/Hidden&gt;
      &lt;RunOnlyIfIdle&gt;false&lt;/RunOnlyIfIdle&gt;
      &lt;WakeToRun&gt;false&lt;/WakeToRun&gt;
      &lt;ExecutionTimeLimit&gt;PT1H&lt;/ExecutionTimeLimit&gt;
      &lt;Priority&gt;7&lt;/Priority&gt;
    &lt;/Settings&gt;
    &lt;Actions Context="Author"&gt;
      &lt;Exec&gt;
        &lt;Command&gt;C:\inetpub\wwwroot\tasks\azcopy.bat&lt;/Command&gt;
        &lt;WorkingDirectory&gt;C:\inetpub\wwwroot\tasks\&lt;/WorkingDirectory&gt;
      &lt;/Exec&gt;
    &lt;/Actions&gt;
  &lt;/Task&gt;
  </code></pre>