Robocopy script Error 3 when run by tackscheduler

jserink

New member
Local time
6:05 AM
Messages
3
Hi All:

I have a script that is using robocopy and here it is:
rem remove the shares initiallynet use \\192.168.49.160\Archive2 /deletenet use \\192.168.49.132\GNSSData /delete
net use \\192.168.49.160\Archive2 /user:ntripweb ThePasswordnet use \\192.168.49.132\GNSSData /user:ntripweb ThePassword
robocopy \\192.168.49.160\Archive2\AlloyDirect\RefData.24 \\192.168.49.132\GNSSData\AlloyDirect\RefData.24 /S /Z /mt:16 /xf /min:2000000 /MAXAGE:120 /LOG+:Alloycopylog\Alloycopy-%date:~-4,4%"-"%date:~-7,2%"-"%date:~-10,2%.log /NP /r:3 /W:5
rem remove the sharesnet use \\192.168.49.160\Archive2 /deletenet use \\192.168.49.132\GNSSData /delete

This is in a bat file that is called every hour and is run under the account "NAS1\ntripweb".
If I leave it to run by task scheduler, when the date ticks over(the files are organized by date) it fails with the following:
New File 2.8 m \\192.168.49.160\Archive2\AlloyDirect\RefData.24\Month.Dec\Day.11\GUWA_Guwah202412111500A.T022024/12/13 12:08:03 ERROR 2 (0x00000002) Copying File \\192.168.49.160\Archive2\AlloyDirect\RefData.24\Month.Dec\Day.11\GUWA_Guwah202412111500A.T02The system cannot find the file specified.ERROR: RETRY LIMIT EXCEEDED.

For some reason, the script cannot create the new directory Day.11. The directory that the destination is in is owned by "ntripweb", the directory also has full permissions control to "ntripweb" to the local and files and folders beneath it.
This happens hour after hour.

Now here is the confusing part......
If I bring up "Task Scheduler" as the administrator and right click on that task and select run......it works.
But if I leave it for task scheduler to run it fails until that subdirectory Day.11 is created.

This is very weird.

Any ideas?

Cheers,
John
 

My Computers

System One System Two

  • Computer type
    Laptop
    OS
    Windows server 2016, 2022, windows10, windows11
  • Computer type
    PC/Desktop
would have to say it sounds like a permissions problem, on the BAT file

to run a batch file with administrative rights. Unfortunately, you can't do this directly from the batch file it self. You would need to first create a shortcut of that batch file and change the properties for that shortcut in order to make this work


Task Scheduler >>RIGHT CLICK<< run with Admin rights
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
medionl/Aspire 6930G/acer x55a
OS
W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
CPU
E5300 dual core
Motherboard
medion MS7366
Memory
3gb
Graphics Card(s)
Nvidia Geforce 7100 Nforce 630i
Monitor(s) Displays
avixc
Internet Speed
n (isp resticted to 72)
Antivirus
mse/pands
Browser
palemoon
Other Info
Belkin Fd7050 n USB using Railink RT2870 drivers, more upto date
my goal is to NOT run with admin rights.
The script works when I right click on the taskand select run. I get the problem with creating the new directory only when the task scheduler runs the task.
 

My Computers

System One System Two

  • Computer type
    Laptop
    OS
    Windows server 2016, 2022, windows10, windows11
  • Computer type
    PC/Desktop
Do a dummy run with the shortcut, if it works then unfortunately your going to have to run it with admin rights
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
medionl/Aspire 6930G/acer x55a
OS
W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
CPU
E5300 dual core
Motherboard
medion MS7366
Memory
3gb
Graphics Card(s)
Nvidia Geforce 7100 Nforce 630i
Monitor(s) Displays
avixc
Internet Speed
n (isp resticted to 72)
Antivirus
mse/pands
Browser
palemoon
Other Info
Belkin Fd7050 n USB using Railink RT2870 drivers, more upto date
No. I am already using UNC drives.
The odd things are these:
1. If I right click on the task ad run it, it works. If it runs as scheduled, I get error 3.
2. After about 18 hours of error 3, it starts working.

I am definitely missing somethig here.
john

- - - Updated - - -

So....still running the task under the account ntripweb.....
And it still fails until.....
So, on Dec 14, it succeeded at the 2346 run. On Dec 15 it succeeded on the 2146 run.
Still waiting for success today. Its strange that it fails for 21-23 hours and then works.
I really don't want to elevate the task to admin rights. Something very strange going on here that will no doubt make complete sense after I've figured it out.

Cheers,
John

- - - Updated - - -

This is solved:

using the Local Group Policy Editor I added the following user rights to ntripweb:
Replace a process level token,
Log on as a service.

I don't get the error 3 anymore.

Do note that "Log on as a batch job" is automatically given to ntripweb when the task is created.

Cheers,
john
 

My Computers

System One System Two

  • Computer type
    Laptop
    OS
    Windows server 2016, 2022, windows10, windows11
  • Computer type
    PC/Desktop
Back
Top