Office Automation How to set up a scheduled task schedule on a Windows computer

Mondo Technology Updated on 2024-02-01

In Windows, we can use the task scheduler to create and manage scheduled tasks. Task Scheduler is a feature that comes with the Windows operating system that can help us automate some repetitive tasks, such as backing up files, updating software, etc.

First, we need to open the task scheduler. There are several ways to do this:

Search for "Task Scheduler" in the Start menu and tap Open. Press on your keyboardwin + rKey combination to open the Run dialog box, entertaskschd.msc, and then tap OK. Right-click on "Computer" or "This Computer" on the desktop, select "Manage", and select "Task Scheduler" in the pop-up window. In the task scheduler, we can create two types of tasks: basic and recurring. A basic task refers to a task that is performed only once, while a periodic task refers to a task that is repeated at a certain interval of time. Let's take creating a basic task as an example to describe how to set a scheduled task schedule.

In the task scheduler, click "Create Basic Task" on the right.

In the Create Basic Task Wizard window, enter a name and description of the task, and then click Next.

Select the trigger for the task. A trigger is when a certain condition is met and the task is automatically executed. There are several types of triggers that we can choose from:

On login: When a user logs on to the computer, the task is executed automatically.

Schedule: You can set a specific start time and date, and when this point in time is reached, the task will be executed automatically.

Idle time: When the computer is idle, the task is executed automatically.

When the system starts: When the computer starts, the task is executed automatically.

Select a trigger as needed, and then tap Next.

Select the action you want to take. Here we can select "Start Program" and click on "Next".

Browse and select the program or script you want to execute, and then click "Next".

After confirming that the task settings are correct, click "Finish".

At this point, we have successfully created a basic task. When the trigger condition is met, the task is executed automatically.

In addition to basic tasks, we can also use the task scheduler to create recurring tasks. A recurring task is a task that is repeated at certain intervals. Here are the steps to create a recurring task:

In the task scheduler, click "Create Basic Task" on the right. In the Create Basic Task Wizard window, enter a name and description of the task, and then click Next. Select the trigger for the task. Here we select "Schedule" and then click "Next". Set the start time and date of the task, as well as the recurrence interval. For example, we can set the task to be executed at 1 a.m. every day and click "Next". Select the action you want to take. Here we can select "Start Program" and click on "Next". Browse and select the program or script you want to execute, and then click "Next". After confirming that the task settings are correct, click "Finish". At this point, we have successfully created a recurring task. The task repeats at the intervals we set.

In the task scheduler, we can view and manage the tasks that have already been created. Here's how to view and manage the tasks you've created:

In Task Scheduler, you can see a list of tasks on the left. All the tasks that have been created are listed here. Select a task to see the details of the task on the right, including triggers, actions, statuses, and more. If you need to modify a created task, you can right-click the task, select Edit, and then modify the task settings in the pop-up window. If you want to delete a created task, right-click the task and choose Delete. If you need to view the history of a created task, you can right-click on the task, select "Properties", and then switch to the "History" tab in the pop-up window. All execution records for the task are listed here.

While using the task scheduler, you may encounter some issues. Here are some common problems and how to fix them:

Issue: Unable to create a new basic task or a recurring task. Workaround: Check if you have permission to create a new task. If you don't have permissions, contact your system administrator. Issue: Created tasks are not executing as expected. Solution: Check whether the trigger settings are correct. If the trigger is set to On sign-in, make sure the user is already signed in; If the trigger is set to Scheduled, check that the start time and date are correct; If the trigger is set to Idle Time, make sure the computer is idle; If the trigger is set to On System Startup, make sure the computer is already booted. Issue: Created tasks are not being repeated as often as expected. Solution: Check that the recurrence interval is set correctly. If the recurrence interval is set to a longer time interval such as one day or a week, make sure that your computer's system time and date are set correctly; If the recurrence interval is set to a shorter interval, such as a few minutes, make sure that your computer's system resources are sufficient to prevent the task from executing on time for other reasons. Issue: Created tasks are not performing as expected. Solution: Check whether the operation settings are correct. If the action is set to Launcher, make sure that the specified program or script path is correct; If the action is set to a different type (e.g., send email, display message, etc.), make sure that the settings are correct. Issue: Unable to view the history of tasks that have been created. Workaround: Check if you have permission to view history. If you don't have permissions, contact your system administrator. Also, be aware that history can be affected by the event log retention policy, which may be deleted if the event log retention policy is set to a shorter period of time, such as a few days. bat as an entry, and bring up other scripts: bat:

f:/python38/python.exe git_util.py

python:

def write_add(path,str,encoding='utf-8'):

with open(path, 'a+',encoding=encoding) as file:

file.write(str)

def pull(local_path):

try: Switches to the specified directory.

os.chdir(local_path)

log_str = time_util.print_now() "The update was successfully pulled"

file_util.write_add(r'd:\users\pengzuo\pycharmprojects\cmd\cmd\util\git.log', log_str)

# subprocess.run(["git", "pull"], check=true, shell=true)

print(log_str)

except subprocess.calledprocesserror as e:

print(f"Error pulling update:")

Related Pages