Hi Pat,
Can you check try the troubleshoot the issue?
*Confirm the task exists and is set up correctly, open the Task Scheduler then expand Task Scheduler Library then find your task. Right-click then Properties on the General Tab, “Run with highest privileges” should be checked and “Configure for” set to your version of Windows. Then under Triggers Tab, ensure the trigger is set to “At startup”. Under Actions Tab, Make sure the action is “Start a program” and the program/script should be [cmd.exe] then add arguments [/c "path\to\your\script.bat"] replace path\to\your\script.bat with the actual full path to the batch file. Under Conditions Tab, uncheck “Start the task only if the computer is on AC power” and uncheck “Start the task only if the network connection is available”.
*Manually run the task, in Task Scheduler, right-click the task and choose Run. Check if the file gets copied to the local folder. If it doesn’t work, the problem is likely in the batch script itself.
*Add logging to the script to capture errors, edit your .bat file and make it like this @echo off
echo %date% %time%: Starting script >> "%USERPROFILE%\Desktop\sync_log.txt"
xcopy "%USERPROFILE%\OneDrive\Documents\YourFile.docx" "%USERPROFILE%\Documents\CopiedDocs" /Y >> "%USERPROFILE%\Desktop\sync_log.txt" 2>&1
echo %date% %time%: Script ended >> "%USERPROFILE%\Desktop\sync_log.txt".
Replace "YourFile.docx" with the name of your test file. After a reboot or task run, check the sync_log.txt file on your Desktop to see what happened.
*Check if OneDrive is ready at startup, if OneDrive hasn't fully synced at system startup, the file might not be available yet. Add a delay in your script before the copy command [timeout /t 30]. Put this right before the xcopy command to wait 30 seconds after login/startup.