title: How to debug this scheduled .bat task in task scheduler using cmd and log file?
body: <p>I'm trying to basically run the following .bat file as a scheduled task, while also logging errors in a .txt file:</p>
  
  <p><a href="https://i.stack.imgur.com/Rwi5R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rwi5R.png" alt="enter image description here"></a></p>
  
  <p>In the 'program/script' box, I just have cmd. Then in the add arguments box I have: </p>
  
  <pre><code>/k ""T:\Some_folder\mybatchfile.bat" &gt;&gt;"T:\somelog.txt" 2&gt;&amp;1"
  </code></pre>
  
  <p>This had been working just fine originally before I tried to add the log function  and calling cmd <a href="https://stackoverflow.com/questions/8662024/how-do-i-capture-the-output-of-a-script-if-it-is-being-ran-by-the-task-scheduler">explicitly</a> as seen in several posts, but I'd really like to add this function. I'm using <a href="https://stackoverflow.com/questions/515309/what-does-cmd-c-mean">/k</a> for now so that I can watch the cmd window as things happen, but plan to replace it with /c so it closes when its done. </p>
  
  <p>I tried many permutations of where <a href="https://stackoverflow.com/questions/6376113/how-do-i-use-spaces-in-the-command-prompt?noredirect=1&amp;lq=1">my quotation marks</a> are but am not having a lot of luck. I'm also intentionally using >> vs > in order to <a href="https://stackoverflow.com/a/8665989/3348414">append the log</a>, not overwrite it.</p>
  
  <p>The contents of the .bat file are basically:</p>
  
  <pre><code>"C:\RDirectory\R.exe" CMD BATCH          "T:\Some_folder1\Preworkforbatch.R"
  copy T:\Some_folder2\some_data.csv       "C:\Users\ABC1\Another_folder"
  copy T:\Some_folder3\some_more_data*.csv "C:\Users\ABC1\Another_folder"
  </code></pre>
  
  <p>I'm wondering if part of it is that T is a network folder that is mapped? Thanks for your help.</p>
  
  <p>edit:</p>
  
  <p>Here is more info on the task:</p>
  
  <p><a href="https://i.stack.imgur.com/h88Si.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h88Si.png" alt="enter image description here"></a></p>