windows 7 - Win7 Task Scheduler Won't Run Copy Commands

06
2014-04
  • user296941

    I'm trying to run a patch file every morning at 4am. For whatever reason, the lines in the batch file that use robocopy.exe are skipped. I've also tried xcopy and cp(from UnxUtils). The batch file works perfectly if I manually run it. When task schedule runs the batch file it hits every single line perfectly, but ignores the lines that use robocopy. There are other lines in the batch file that call other executables, and those work just fine.

    I can't for the life of me figure out what is going on. I set up some logging in the batch file to make sure it was hitting all the points and it is. It just does not execute the robocopy lines.

    Any help would be appreciated.

  • Answers
  • Stephan

    I just add the same problem, it seem that Task Scheduler has problem using mapped drive. So I change the map drive to use the UNC path and everything started working.

    robocopy C:\Data J:\Backup *.*
    

    changed for

    robocopy C:\Data \\ServerName\Backup *.*
    

  • Related Question

    Task scheduling Batch Files in Vista
  • Questioner

    Wondering if there is some trick to scheduling a batch file to run in Vista.

    I have tried almost every setting/arg I can think of with no result other than an error, or the command window opening then instantly closing without executing the code.

    The batch files works fine when I double click to run.


  • Related Answers
  • John T

    I figured out the issue.

    If you have a batch file you want to run, the path to the batch file can not have any spaces in it (even if you include quotes).

    Putting the batch file in C:\ allowed it to run via Task Scheduler.

  • fluxtendu

    To work around this problem, enclose the path portion of the task (not including arguments or switches) between backslash (\) and quotation marks (") character combinations, for example \". Enclose the complete path of the task (including arguments or switches) between quotation marks as usual when you create a path or command that contains spaces.

    schtasks /create /tn "my task" /tr "\"c:\foldername name containing spaces\script.bat\" arguments" /sc once /sd 07/29/2003 /st 10:01
    

    source: support.microsoft.com