Task scheduler not running my batch correctly

January 5, 2011 at 20:12:59
Specs: Windows 7 64 bit
I'm having an issue with this batch file running through Task Scheduler.
The problem is that when the scheduled task runs it does everything except the last part. It will not copy and Task Scheduler returns (0x2) as the result.
However, when I run the batch file manually, it processes the whole file successfully. The copy works...??? The task is set to run under administrator...

Copy of my batch file:
if exist D:\Torrents\_MKV_Results.txt del D:\Torrents\_MKV_Results.txt
if exist D:\Torrents\_MKV_Results2.txt del D:\Torrents\_MKV_Results2.txt
sqlcmd -S ENCODER\SQLEXPRESS -d DEFAULT -E -i D:\Torrents\_CHK.sql -o D:\Torrents\_MKV_Results.txt -h-1
CHOICE /T:4 /D:y
call D:\Torrents\_rtrim.bat
@echo off
setlocal enabledelayedexpansion
for /F "tokens=*" %%a in (D:\Torrents\_MKV_Results2.txt) do C:\StaxRip\StaxRip.exe D:\Torrents\Done\%%a.mkv -encode -exit

@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%2 in (D:\Torrents\_MKV_Results2.txt) do Copy D:\Torrents\Done\%%2.mp4 Z:\


See More: Task scheduler not running my batch correctly

Report •

#1
January 6, 2011 at 05:57:52
I assume your Z: is a network drive you mapped. Task Manager doesn't have access to drives you mapped. The solution is to have your script map the drive itself.

How To Ask Questions The Smart Way


Report •

#2
January 6, 2011 at 06:00:03
You mean to use UNC path?

Report •

#3
January 6, 2011 at 06:11:24
That'd remove the requirement of mapping the drive in the first place, so sure.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
January 6, 2011 at 09:38:32
That worked...Thanx Razor

Report •

Ask Question