Batch job won't run with task scheduler
Moderator: DosItHelp
Batch job won't run with task scheduler
Hey guys,
I have a batch job that i set up using windows 2003, I setup a simple copy command to copy some files over to a mapped directory several times a day. The problem lies when running it through task manager it runs, but doesn't execute the batch file.
Running the code manually in dos works, copy paste... running it through dos and calling the batchfile run's fine as well. The file has two commands to execute, I have even put the absolute path in the dest instead of using a mapped drive.
Xcopy D:\source\*.* Z:\dest\*.* /d /f /y /e /c >> F:\log.txt
I did a test and changed the dest directory to a local drive and it worked with task scheduler.. so looks like it has to do with the mapped drive.. but absolute path didn't work either..
maybe use net user in batch file?
Suggestions.. Thanks
I have a batch job that i set up using windows 2003, I setup a simple copy command to copy some files over to a mapped directory several times a day. The problem lies when running it through task manager it runs, but doesn't execute the batch file.
Running the code manually in dos works, copy paste... running it through dos and calling the batchfile run's fine as well. The file has two commands to execute, I have even put the absolute path in the dest instead of using a mapped drive.
Xcopy D:\source\*.* Z:\dest\*.* /d /f /y /e /c >> F:\log.txt
I did a test and changed the dest directory to a local drive and it worked with task scheduler.. so looks like it has to do with the mapped drive.. but absolute path didn't work either..
maybe use net user in batch file?
Suggestions.. Thanks
Last edited by chev on 23 Sep 2016 13:31, edited 1 time in total.
Re: Batch job won't run with task scheduler
Yes you need to use the UNC path and you also have to set a username and password in the task properties for a user that has access to that network resource.
Re: Batch job won't run with task scheduler
I used the UNC path in the batch file, and yes have the user and password in the task scheduler, the UNC in the batch file didn't work.
are you suggesting I use the net use in the batch file as well as the UNC?
so
net use z:\ path -----> checked in dos
Xcopy D:\source\*.* Z:\dest\absolute_path\*.* /d /f /y /e /c >> F:\log.txt
are you suggesting I use the net use in the batch file as well as the UNC?
so
net use z:\ path -----> checked in dos
Xcopy D:\source\*.* Z:\dest\absolute_path\*.* /d /f /y /e /c >> F:\log.txt
Re: Batch job won't run with task scheduler
chev wrote:I used the UNC path in the batch file, and yes have the user and password in the task scheduler, the UNC in the batch file didn't work.
I know it works. This is what I do for a living. Data automation. I have 4 servers and 800 automation tasks. Close to 100 of those tasks are Windows Scheduled Tasks running batch files.
chev wrote: are you suggesting I use the net use in the batch file as well as the UNC?
so
net use z:\ path -----> checked in dos
Xcopy D:\source\*.* Z:\dest\absolute_path\*.* /d /f /y /e /c >> F:\log.txt
That works as well. But again you don't even need to assign it a drive letter. You can authenticate with the NET USE command to the UNC path and still use the UNC path in the batch file. I discussed this a while back on the forums.
Re: Batch job won't run with task scheduler
Here is the thread where I talked about using the NET USE command without assigning a drive letter. I have only ever used this method once and I can't remember why. Window Task Scheduler has never failed if I put in the correct credentials for access to the network resource.
viewtopic.php?f=3&t=5247
viewtopic.php?f=3&t=5247
Re: Batch job won't run with task scheduler
Squashman wrote:Window Task Scheduler has never failed if I put in the correct credentials for access to the network resource.
That's the key I think. The system account doesn't have access to any network resources.
Re: Batch job won't run with task scheduler
you guys are absolutely right.. The issue is with the maintenance account that task scheduler has assigned to it doesn't have the correct privs to the share...
Thanks for all the input... Appreciated..
Thanks for all the input... Appreciated..
Re: Batch job won't run with task scheduler
So, I have another issue with this same situation.. again this is windows 2003....You can login and run the jobs manually through task scheduler, works fine. But if you log off the server and in my case the service account the jobs will execute but they won't do the job...
for instance I have my jobs outputted to a log file and they are just copying files off of the server...
Logged in, copy just fine... logged out I get 0 files copied and verified..
any ideas, suggestions would be great.. thanks
for instance I have my jobs outputted to a log file and they are just copying files off of the server...
Logged in, copy just fine... logged out I get 0 files copied and verified..
any ideas, suggestions would be great.. thanks
Re: Batch job won't run with task scheduler
thinking about it too.. I have other batch files that don't do copies off, that execute just fine... seems like its a problem with xcopy and when the server isn't logged in thats the problem.. is there a special switch maybe that needs to be put into place?
Re: Batch job won't run with task scheduler
chev wrote:thinking about it too.. I have other batch files that don't do copies off, that execute just fine... seems like its a problem with xcopy and when the server isn't logged in thats the problem.. is there a special switch maybe that needs to be put into place?
Just going to reiterate what I already said.
UNC paths.
Username and password configured in the scheduled task that has access to the needed resources.
Re: Batch job won't run with task scheduler
Squashman wrote:chev wrote:thinking about it too.. I have other batch files that don't do copies off, that execute just fine... seems like its a problem with xcopy and when the server isn't logged in thats the problem.. is there a special switch maybe that needs to be put into place?
Just going to reiterate what I already said.
UNC paths.
Username and password configured in the scheduled task that has access to the needed resources.
I see your point and I would think if that was the problem when I run the batch jobs manually( with task scheduler) (or scheduled) while logged into the server everything works fine.
When the server is not logged in, the jobs execute, but don't copy the files.. When I say execute, I see in the logfiles that 0 files copied..
Re: Batch job won't run with task scheduler
chev wrote:Squashman wrote:chev wrote:thinking about it too.. I have other batch files that don't do copies off, that execute just fine... seems like its a problem with xcopy and when the server isn't logged in thats the problem.. is there a special switch maybe that needs to be put into place?
Just going to reiterate what I already said.
UNC paths.
Username and password configured in the scheduled task that has access to the needed resources.
I see your point and I would think if that was the problem when I run the batch jobs manually( with task scheduler) (or scheduled) while logged into the server everything works fine.
When the server is not logged in, the jobs execute, but don't copy the files.. When I say execute, I see in the logfiles that 0 files copied..
I can't see your batch file and I can't see how your task is configured so I just have to take your word that you have everything setup correctly. But I can tell you from my experience that it does work they way I have described it otherwise my boss would be screaming at me every day that we are not meeting our SLA's (service level agreements) with our clients.
Re: Batch job won't run with task scheduler
chev wrote: I see your point and I would think if that was the problem when I run the batch jobs manually( with task scheduler) (or scheduled) while logged into the server everything works fine.
That's not the same as running the task without being logged in.
Test Squashman's advice once more.
Re: Batch job won't run with task scheduler
make a new task scheduler is the best choice
i think your old task sch there's no enough user right, may be you have change pass of user or win,
i think your old task sch there's no enough user right, may be you have change pass of user or win,