I am running a .py file from Windows Task Scheduler. For most files this works fine as follows:
- Create new task in TS
- In TS on the "Actions" tab under "Program/script:" specify the path to python.exe (Example: C:\Users\User\Python.exe)
- In TS in the "Add arguments" section, add the path to the .py file in quotes (Example: "C:\Path\To\Py\pythonfiletorun.py")
When this works correctly, Python.exe pops up for a split second, runs the program and vanishes.
However, I have one .py file that isn't working. When I try to run it from QT Console it works fine. When I use the TS process it fails. And the Python.exe closes so fast I can't see what is wrong.
I tried converting everything to a batch file so "Program/script" becomes "cmd" and "Add arguments" becomes: /k "C:\Path\To\batchfile.bat" which then houses the paths and instructions.
This opens a command prompt (and keeps it open) but from here the main command prompt opens the python.exe command prompt which runs and closes just as fast.
I tried placing the /k in various places to no avail.
I also tried putting an input qualifier at the end of the .py script (Ex: input("Press any key to...") in hopes that would cause the Python.exe command to stay open but it doesn't.
Ultimately, I need the Python.exe command to stay open to see what is wrong.