I already tried to convert my .py file into .exe file. Unfortunately, the .exe file gives problems; I believe this is because my code is fairly complicated. So, I am trying to schedule directly my .py file with Task Scheduler but every time I do it and then run it to see if works, a window pops up and asks me how I would like to open the program?-.-
Does any of you know how I can successfully schedule my .py file with Task Scheduler?
Windows 10 Python 3.5.2
Creating the exe should be the best method. But if you want to run it with the task scheduler you can do it in this way:
To ensure that your Python script will run regardless of the login account that the schedule task uses, and to avoid any confusion about which version of Python is used in mixed environments (64bit or 32bit), it is recommended that you run the Python executable with the name of your Python file as an argument to the executable.
Suppose the script you want to run is E:\My script.py. Instead of running the script directly, instruct the task scheduler to run python.exe with the script as an argument. For example:
C:\Python27\ArcGIS10.2\python.exe "E:\My script.py"
The location of python.exe depends on your install. If you don’t know where it is, you can discover its location; copy and paste the following code into a new Python script then execute the script. The script will print the location of python.exe as well as other information about your Python environment.
import sys
import platform
import imp
print("Python EXE : " + sys.executable)
print("Architecture : " + platform.architecture()[0])
print("Path to arcpy : " + imp.find_module("arcpy")[1])
raw_input("\n\nPress ENTER to quit")
After determining the location of python.exe, this is what is entered in the Action panel of the task scheduler:
If there are additional arguments (parameters) to your script, provide them after the path to your script. Hope this helps.