Running Python to kick off a batch job works fine with Pycharm but not with Microsoft Task Scheduler

I have a piece of code that kicks off a command line batch job from Python.

 

The code snippet is as follows:

run_batch = r'C:\Users\username\Downloads\download'
os.system(run_batch)

This works when I run it from Pycharm but when I run it using Microsoft Task Scheduler, it refuse to kick off the command line batch job.

When I issue the same command as configured in the Task Scheduler to run the Python code manually with the command line terminal, it initiates the batch job as expected.

In all cases, they are running off the same python.exe.  The configruation in Pycharm uses the same Python executable as the Task Manager and the command line.

Does anyone else have the same problem and did you manage to solve it?  I would like to hear from you.

 

Thanks.

Please sign in to leave a comment.