In Windows I have come up with two solutions.
First option: Create a .bat file.
Step 1
Create a .bat file to indicate the command you want to run and the script file that will be executed, for instance:
start C:\Users\userX\Python.exe C:\Users\userX\PycharmProjects\Automation_tasks\create_workbook.py
Step 2
Open the Task Scheduler and click on the Task Scheduler Library to see the current tasks that are executed. Click on the Create Task option.

Step 3
In the General tab, put the name of your new task and click on the option Run whether user is logged on or not
, check the option Run with highest privileges
and make sure to setup the appropriate version of you OS (in my case I picked Windows 7, Windows Server 2008 R2
.

Step 4
In the Actions tab, click on the New button and type in the following:
In Program/Scripts you need to look up for the Powershell path that the Task Scheduler will invoke to run the .bat file. In my case, my Powershell path was:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
In Add arguments (optional) you need to type the path of the file that will be executed by Powershell. In my case, the path was:
C:\Users\userX\Desktop\run_the_bat_file.bat
In Start in (optional) you need to type the path of the file but without the name of the .bat file, that is:
C:\Users\userX\Desktop\

Step 5
Click on the Triggers tab and select how often you want to execute this task.

Step 6
Lastly, test your task to see if it truly works by selecting it from the Task Scheduler Library and doing click on the Run option.

Second option: Run the .py file with the Task Scheduler
Step 1
Open the Task Scheduler and click on the Task Scheduler Library to see the current tasks that are executed. Click on the Create Task option.

Step 2
In the General tab, put the name of your new task and click on the option Run whether user is logged on or not
, check the option Run with highest privileges
and make sure to setup the appropriate version of you OS (in my case I picked Windows 7, Windows Server 2008 R2
.

Step 3
In the Actions tab, click on the New button and type in the following:
In Program/Scripts you need to look up for the Python.exe path that the Task Scheduler will invoke to run the python script. In my case, my Python.exe path was:
C:\Users\userX\python.exe
In Add arguments (optional) you need to only type the name of your python script. In my case, the path was:
Permissions_dump.py
In Start in (optional) you need to type the path of the file but without the name of the python script, that is:
C:\Users\userX\PycharmProjects\1099_vendors_costs

Step 4
Click on the Triggers tab and select how often you want to execute this task.

Step 5
Lastly, test your task to see if it truly works by selecting it from the Task Scheduler Library and doing click on the Run option.

Another option (in case you convert a .py to a .exe)
If you use the library Cx_Freeze to convert a .py to a .exe and you want to use the task scheduler to automate this task then you need to follow these steps:
Step 1
Click on Create Task and then click on the Actions tab to type in the following:
In Program/Scripts you need to look up for the C:\Windows\explorer.exe
path that the Task Scheduler will invoke to run the .exe script.
In Add arguments (optional) you need to only type the name of your .exe file: CustomerPopulation.exe
In Start in (optional) you need to type the path of the file but without the name of the .exe file, that is:
C:\Users\userX\PycharmProjects\executables

In the General tab, make sure to have selected the Run only when user is logged on
and have unchecked the Run with the highest privileges
.
If reports stopped working
Make sure to check if your password hasn’t expired, otherwise the reports won’t be sent.
References:
- https://gis.stackexchange.com/questions/140110/running-python-script-in-task-scheduler-script-will-not-run?newreg=603bcdbc381b41a283e5d8d0561b835e
- https://www.youtube.com/watch?v=oJ4nktysxnE
- https://www.youtube.com/watch?v=n2Cr_YRQk7o
cron
, if you are on a Linux or Mac machine?