Link to home
Start Free TrialLog in
Avatar of jdana
jdanaFlag for United States of America

asked on

Windows, Scheduled Tasks associated with batch files are failing

I configured a Scheduled Task that resides on my Mac (Parallels v10.3, Windows 8), to run a batch file that calls iPerf. The batch file works fine when I call it manually, but fails when I call it with a scheduled task. Here's the batch file.

iperf3 -c 10.20.2.2 -P 1 -p 5201 -f K -V -J -t 10 --logfile "C:\DSD\iPerf\log\COURTROOM_5TH_FL_%computername%_%date:~10%%date:~4,2%%date:~7,2%-iperf.txt"

Open in new window

In an effort to isolate the issue, I created a simpler batch file. Again, the batch file works fine when I call it manually, but fails when I call it from the scheduled task.

dir /b > dirlist.txt

Open in new window

Finally, I created this batch file. This works when I call it manually and when I call it with the scheduled task.

Notepad.exe

Open in new window

So, the scheduled tasks fail based on the functionality of the batch file. Perhaps it's a Windows security issue. If I change the task to Run whether user is logged in or not, the scheduled task simply hangs.

User generated imageI activated history in scheduled tasks. History doesn't appear to show me much of use. Here, for example I've configured the scheduled task to run a batch file that doesn't exist, the results look no different.

User generated image
Avatar of McKnife
McKnife
Flag of Germany image

Shouldn't be complicated. Write your command into a batch file, create a new task with that batch file as action. Works here with dir /b > dirlist.txt
Avatar of jdana

ASKER

That's exactly what I did. Doesn't work here with dir /b > dirlist.txt.
Run Scheduled Tasks as Administrator.
My user account is local admin.
Tried dropping tasks in other folders in Task Scheduler.

User generated imageI'm scratching my head.
Describe the error, your task history screenshot does not show errors.
a return code of 2 is a file not found error. ergo add the full path to the executable.
Avatar of jdana

ASKER

Progress. I added a PAUSE to the batch file. As before, I can successfully call it from the task scheduler, but check out the extra 1 immediately in front of > dirlist.

User generated imageHere's the batch file itself. The 1 isn't there. Again, this works properly if I call it manually.

User generated image
Avatar of jdana

ASKER

Solved. Start In = Specifying the directory in which the batch file resides. User generated image
ASKER CERTIFIED SOLUTION
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
nevermind, I see you actually noticed the issue in the end, but didn't mark the item as closed.
Avatar of jdana

ASKER

Thanks!