RoboCopy does not run in Task Scheduler

Mark 21 Reputation points
2022-11-25T01:38:37.773+00:00

I have a very simple one line command in a .bat file I have named BackupProg.bat

robocopy G:\ Y:\backupdata2\ /MIR /XO

I have also tried robocopy G:\ Y:\backupdata2\

If I run the file out of windows explorer, it runs perfectly
If I run the file out of Task Scheduler it does absolutely nothing. It runs the file just not the RoboCopy command.

I am running Windows 11 Pro

I have tried both Run only when user is logged on and Run whether user is logged on or not.

I have "Run with highest privileges checked"

Hidden is un-checked

I have tried to configured for windows 10, 7 & Vista

I know the file does run as I have put a msg * "The backup file just ran" and it shows this message on my screen for testing.

The History tab in the task says "History (disabled)"

I do have a password on the computer and I enter that password when I save the task. Like I said it does run the task just not the RoboCopy command.

Any help would be appreciated.
Thanks
Mark

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,227 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 31,826 Reputation points
    2022-11-25T02:04:41.47+00:00

    It is probably a mapped drive issue. The task scheduler just does a user impersonation and depending on how you mapped the drives they might not be visible. The simplest solution is to use the UNC path, \server\share\, instead of the drive letter.

    Modify your BackupProg.bat file to execute these commands.

    dir G:\  
    dir Y:\  
    robocopy G:\ Y:\backupdata2\ /MIR   
    

    Configure the task scheduler to execute program cmd.exe. In the arguments field put "/c c:\YourFolderName\BackupProg.bat 1> c:\YourFolderName\BackupProg.log 2>&1"

    Run the task and check the log file contents. The dir commands will verify that the drive letters are visible/accessible. The redirects will capture stdout and stderr.


2 additional answers

Sort by: Most helpful
  1. Kevin Cornett 31 Reputation points
    2023-07-27T17:46:39.1466667+00:00

    This will work all day in Windows 10. I have a script that has a Robocopy line, which copies files from one location to another, and it uses UNC path. I ran the script yesterday on nearly 75 computers running Windows 10 and every one ran successfully. This morning I ran it on a Windows 11 computer, and the Robocopy line just sits there and does nothing. This is a Windows 11 issue.

    if exist c:\apps\2023_7_26_update_2023_1 goto next1
    	md c:\apps\2023_7_26_update_2023_1
    
    	robocopy \\<IP ADDRESS>\c$\Apps\2023_7_26_update_2023_1 c:\apps\2023_7_26_update_2023_1\ /E /R:3 /W:5
    

  2. J.D. Mallen 0 Reputation points
    2024-04-24T03:56:49.67+00:00

    I ran into the same thing. Solved it by mapping the network drive as part of the script. The /p flag is to ensure the mapping doesn't persist between user sessions, in case the script gets interrupted before the last command.

    net use G: \\path\to\network\folder1 /p:no
    net use Y: \\path\to\network\folder2 /p:no
    :: do your script stuff here ::
    net use G: /delete
    net use Y: /delete
    

    For whatever reason, even if you use the first commands in an admin cmd window outside of Task Scheduler (with /p:yes) to map the drive for the admin user, it won't see the mappings when executing the "highest privileges" task. You can see them everywhere else, though-- e.g. if you went to File/Open... in an Admin Notepad. Not sure why this is so.

    0 comments No comments