Question Locked

Task Scheduler

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I created a batch file to move text files from a server (local drive C) to a mapped drive using Windows Task Scheduler. So far, It has not been working properly. I would always have to login to the server, find the batch file and dbl click on the txt file to move the files from local drive C to the mapped drive. I want to know why can't it move files from the server automatically according to the script.

5 replies

by absolutely

OK, upgrade to *nix at your leisure, I'll try to help, anyway.

[i]I would always have to login to the server,[/i]

Good, you would not want your files accessible from a server that has not logged in -- would you??

[i]... find the batch file and dbl click on the txt file to move the files from local drive C to the mapped drive.[/i]

Your batch file should be on the 'mapped drive,' ie, the batch file should be of type 'pull' not 'push.' In other words, it should say 'copy to my own (local) drive,' not 'copy to (mapped) network hard drive.'

Wakarimaska?

by Member 25348569

Your scheduled batch file can't access a mapped drive unless you map the drive in the batch file before accessing the file on it. Batch files don't run any login scripts or run profile mappings.

So, either get into the (good) habit of using only UNC paths rather than mapped drives or insert the command:

net use X: \\UNC path to resource
...commands to access the drives...

Neil :D

by touchrugbyqueen

Thanks for the reply: The batch file is written to map the drive before moving the files. Here is the batch file (I have changed the names though)...

Sometimes it will work...it's been two weeks and I think it only works once or twice...can it be a network problem?

net use X: \\name.server.domain.edu\activities /user:alo_fileserver kamehameha000 /persistent:no
copy c:\folder1\act1\*.dat X:\
copy c:\folder1\act1\*.dat c:\foler1\act1\Archive\
del c:\folder1\act1\*.dat
copy c:\folder1\act2\*.dat X:\
copy c:\folder1\act2\*.dat c:\folder1\act2\Archive\
del c:\folder1\act2\*.dat

Merry Christmas

by Member 25348569

I'd try a couple of things.

Firstly, I wouldn't use a mapping but copy to a UNC path when copying outside of the local C: drive. The only thing to be sure of then is that the user that you use for the scheduled task has permissions.

I'd use the /Q switch with DEL otherwise it stops on wildcards. If you want to use copy, I'd add the /Y switch so it won't stop on overwrites. (One of these is probably what is happening and your batch file is timing out).

For Archiving, I like to use Microsoft's Robocopy rather than Copy or XCopy. You can then get it to write log files and see what - if anything - is going on. It's also much more versatile.

Send me the fare and I'll pop over and debug it for you. :D

Neil :D

Merry Christmas!

This discussion is closed to new replies.