Matt
Matt

Reputation: 5

Task Scheduler opens command prompt but does not run python script

I run a python script from my command prompt once per day, but I want to automate this with task scheduler. I can only make it open Command Prompt, but I have to then run the python program manually. What am I missing?

  1. New Folder myTasks
  2. Create basic Task
  3. Task name, trigger, start a program
  4. Program script/ cmd.exe
  5. Add Arguments: "C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py"
  6. Manually Run Task to test it

All I get is the command prompt opening up and it displays: C:\WINDOWS\system32>

It wont actually run the python script. If I type python "C:\Users\Matthew Olive\PycharmProjects\VOLALGO1\scraper.py"after C:\WINDOWS\system32> it will run just fine.

Upvotes: 0

Views: 2278

Answers (2)

Matt
Matt

Reputation: 5

Thanks CaffeinatedCoder! I figured it out!

I used exactly that for the program/script and it worked. Turns out it was running in the python terminal, but it would disappear immediately, so I added input("Press Enter to Exit...")to the end of the python script.

Upvotes: 0

CaffeinatedMike
CaffeinatedMike

Reputation: 1607

Instead of using cmd.exe you could directly use the python.exe with the full path to it. An example location of where it might be is

C:\Users\MyName\AppData\Local\Programs\Python\Python37-32\python.exe

Upvotes: 1

Related Questions