Link to home
Start Free TrialLog in
Avatar of nicksbell
nicksbell

asked on

Why doesn't this Scheduled backup task work?

If i enter the following into COPY.CMD and then register this CMD into
the Schedule Task list I see it run & it exits immediately with error code 4.
Can anyone explain why?

File COPY.CMD
==========
echo "Delete target directories"
del /F /S /Q w:\*.*
echo "Copy Over"
xcopy f:\foo w:\foo /s /Y
xcopy f:\goo w:\goo /s /Y
xcopy f:\hoo w:\hoo /s /Y


The above was run under the Administrator account, F is the local machine, W is
a drive mounted on a separate machine on a local network.

Is it having a problem with the *.* list, there are quite a few files involved.
Avatar of Eagle6990
Eagle6990
Flag of United States of America image

What happens if you manually run the file from a command line? You might be able to see more of what is going on.
Are you trying to delete just the file or the directories as well? If you want to delete the directories then you need to use the rd command.
Avatar of nicksbell
nicksbell

ASKER

Sorry, i should have mentioned that, i can run the CMD file just fine on its own, it is only
when run from the scheduler that it has the problem
I would start rem'ing everything out, or maybe rem out everything and see if it can run then. if it can't, then you know it is an issue with your schedule.  Gradually work it back until you find out exactly which line is causing your error.
The Task Scheduler needs a user name AND password to work.
You may add it to the Task Properties.

Then right click on the task and Run to test

So, i investigated this some more. It seems to be related to the W drive. If i try and use the
same sort of CMD file to just delete (no xcopy) a file on the local C drive it works.

But if i try and delete the same file when it is on the shared W drive it fails!
ASKER CERTIFIED SOLUTION
Avatar of Eagle6990
Eagle6990
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial