- 1 year ago
How to schedule a python script using Task scheduler by using Argument field in Task Scheduler
Comment
1 / 1
To schedule a Python script using Task Scheduler on Windows and pass arguments to the script, follow these steps:
- Open the Task Scheduler by searching for it in the Start menu or by typing
taskschd.msc
in the Run dialog (pressWin + R
). - Click on "Create Task" in the right-hand pane to create a new task.
- In the "General" tab, give the task a name and description.
- In the "Triggers" tab, set the time and frequency at which the task should be run.
- In the "Actions" tab, click "New" and select "Start a program" as the action.
- In the "Program/script" field, enter the path to the Python executable (e.g.
C:\Python39\python.exe
). - In the "Add arguments" field, enter the path to the Python script and any arguments that need to be passed to the script. For example:
"C:\path\to\script.py" --arg1=value1 --arg2=value2
. - Optionally, set the "Start in" field to the directory where the script should be run from.
- Click "OK" to save the task.
Once the task is created, it will run at the specified time and frequency and pass the arguments to the Python script.