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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.