Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduled tasks

Status
Not open for further replies.

kenroush

Programmer
Jan 16, 2002
26
US
I've written a simple batch file which runs perfectly.
However, if I call it from a scheduled task, some of the commands don't work. Specifically, the DOS copy command.

I'd appreciate any suggestions as to why this is happening.
 
Some things to try...

1) Try to add >> c:\testlog.txt at the end of the lines that do not work. Then look in c:\testlog.txt to see the error messages.

2) the copy command is an internal DOS command. Try to replace it by the external xcopy command



 
The only output to the testlog was "o files copied".
Not much help - I already knew that.

Using xcopy didn't change anything.
Thanks for the suggestions anyway.

A little more info:
I'm trying to run this "copy filename*.dat newfile.dat"
It doesn't seem to like the wildcard *. Why not?
 
Make sure the account running the scheduled task has access to the files. Running the batch file works because it's using your account, the default for scheduled tasks is the "Local System" account.
 
Does a copy without wildcards work?

Make sure you specify the entire path before the filenames, or go to the right folder (using cd \dir..) before the copy command.

Could you post the entire batch file in case this does not work?
 
I'm with wimvh on this one, really need to use the full path or god only knows where it will be trying to copy files from or to. Would explain why no files are being copied.
 
It has nothing to do with paths or wildcards as kenroush says "I've written a simple batch file which runs perfectly." It looks like a permission problem with the task scheduler.
 
I think it could still be path related, the batch file may run perfectly when executed from the default path of the DOS prompt (usually related to the user's profile location), but may not be able to find the data when executed from a scheduled task as it will likely start from a different location.

Try putting c: then cd\ as the first two lines of the batch file to ensure its starting from the root of c:, also put in "@echo on" at the start and put a pause command at the end of the batch file so when it runs via the schedule it will keep the DOS window open at the end of the routine so you can better see what went on.

Have you tried simplifying the batch file by only asking it to copy a single file from the same location? If that works then it is as you say the wildcard causing an issue. Have you tried encapsulating it in quotation marks, eg copy "filename*.dat" "newfile.dat" ?
 
I appreciate all of your responses, but I found the problem.
I feel kinda foolish.
I was trying to run the scheduled job thru a 'Remote Desktop' session on my PC. When I finally got off my butt and ran it directly on the server, everything worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top