借助任务计划程序,您可以创建由(Task Scheduler,)Windows运行的各种自动化任务。例如,您可以安排某些应用程序以特定时间间隔运行,或在发生某些事情时在桌面上显示消息。不幸的是,没有多少人知道这个工具,因为Windows没有像它应得的那样宣传它。为了帮助您开始使用它,我们创建了本指南,介绍如何使用任务计划程序(Task Scheduler)提供的基本任务向导(task wizard)。下面是它的工作原理:
如何在Windows中访问(Windows)任务计划程序(Task Scheduler)
如果您想使用任务计划程序(Task Scheduler),您必须首先知道如何打开它。如果您不知道如何操作,我们已经发布了关于此主题的单独指南:在Windows中启动(Windows)任务计划程序(Task Scheduler)的 9 种方法(所有版本)。
如果您也没有时间阅读该教程,在任何现代版本的Windows中打开(Windows)任务计划程序(Task Scheduler)的一种快速方法是使用搜索。在Windows 10的任务栏上Cortana的搜索字段、 (search field)Windows 8.1的“开始(Start)”屏幕上或Windows 7的“开始”菜单(Start Menu, )的搜索字段(search field)中键入单词schedule。然后,单击或点击(click or tap)任务计划程序(Task Scheduler )搜索结果。
在继续之前,请记住任务计划程序在(Task Scheduler)Windows 10、 Windows 7 和Windows 8.1中的外观和工作方式相同。因此,也为了简单起见,我们将主要使用在Windows 10中截取的屏幕截图。
步骤 1(Step 1)。启动“创建基本任务(Create Basic Task)”向导
在“任务计划程序(Task Scheduler)”窗口中,转到右侧的“操作”列。(Actions)在那里,单击或点击“创建基本任务”("Create Basic Task")链接,以打开具有相同名称的向导。
该向导允许任何人在给定时间或满足特定条件时创建由Windows执行的基本任务。(Windows)为了说明整个过程,我们假设您要创建一个定期运行磁盘清理(Disk Cleanup)工具的任务。
步骤 2(Step 2)。为任务命名并给出描述
在向导的第一步,输入新任务的名称和描述。然后,单击或点击下一步(Next)按钮。
步骤 3(Step 3)。选择何时执行新任务
您必须决定任务何时开始。有许多选项可用于选择任务的运行时间:每天、每周、每月、仅一次、每次计算机启动、每次登录或发生特定事件时。这部分过程称为任务触发器(task trigger),换句话说,它是任务运行所需要的。选择您想要的选项,然后按Next。
您必须提供有关任务运行时间的更多详细信息,具体取决于您之前选择的选项。
例如,如果您希望新任务在每周三(Wednesday)晚上 10:00 执行,您应该选择每周(Weekly),然后进行以下配置:
- 设置下周三(Wednesday)晚上 10:00的开始日期和时间;(starting date and time)
- 在“Recur every”字段中,输入 1,表示该任务将每周运行一次;
- 选择星期几作为周三(Wednesday)。
如果选择每月(Monthly)执行任务,除了开始日期和时间(date and time)外,还必须选择任务执行的月份。单击(Click)或点击“月份(Months)”下拉菜单以使任务在特定月份、一年中的所有月份或仅一个月内运行。
然后,您可以通过检查天数(Days)并键入天数或从列表中选择天数来选择该月的某一天或几天。(day or days)
您还可以将任务设置为在特定一周的特定日期运行。为此,请单击或点击“打开”(On)选项。然后,在第一个下拉列表中选择星期几,在第二个下拉列表中选择星期几。
完成任务执行时间设置后,单击或点击(click or tap) 下一步(Next)。
第 4 步(Step 4)。设置要执行的操作
在下一步中,您必须告诉任务计划程序(Task Scheduler)要执行的操作:“启动程序”、“发送电子邮件”("Start a program," "Send an e-mail" )或“显示消息”。("Display a message.")
在这里,一方面Windows 10和Windows 8.1与另一方面(Windows 8.1)Windows 7之间存在本质区别。这三个选项在所有这些Windows版本中都可用,但最后两个在Windows 10和Windows 8.1中突出显示为已弃用,这意味着它们在这些操作系统中不起作用。
即使您可以按照向导创建发送电子邮件或显示消息的任务,但在保存任务之前,您会收到如下所示的错误消息(error message),其中指出“任务定义使用了已弃用的功能。”("The task definition uses a deprecated feature.")
因此,在Windows 10和Windows 8.1中,您无法创建发送电子邮件或显示消息的任务,即使向导显示了这些选项。您只能在Windows 7中创建此类任务。如果您想了解它们的工作原理,请阅读本指南的最后一部分。
但是,让我们继续本教程,看看如何设置任务将要执行的操作:
如果要运行磁盘清理等程序,(Disk Cleanup,)请选择“启动程序”("Start a program" ),然后单击或点击下一步(Next)。
单击或点击浏览(Browse),选择要运行的程序或脚本,然后按打开(Open)。或者,您也可以键入该程序的可执行文件的位置。如果您想要或需要,您可以添加参数并设置程序/脚本开始的文件夹。完成后,按Next。
步骤 5(Step 5)。检查新任务的详细信息并保存
最后,您可以看到任务摘要和您所做的设置。如果要更改任何内容,请单击(Click)或点击返回按钮。(Back)否则(Otherwise),按完成(Finish)按钮。此操作会保存任务并使其能够在您安排它时运行。
如何使用任务计划程序(Task Scheduler)创建发送电子邮件或显示消息的任务(仅在Windows 7中)
如果您使用的是Windows 7,让我们看看如何设置“发送电子邮件”("Send an e-mail")操作:
选择使用此操作并按下(action and press)下一步(Next)按钮后,您必须输入邮件的详细信息:发件人、收件人、电子邮件主题(email subject)和文本内容(text content)。如果需要,您还可以附加文件。最后也是最重要的一步是提供发送电子邮件的SMTP 服务器的地址。(SMTP server)您应该使用您在“发件人(From)”字段中指定的电子邮件地址的(email address)SMTP 服务器。(SMTP server)但是,问题在于大多数 SMTP 服务器在发送任何内容之前都需要进行身份验证,以防止滥用和问题。“创建基本任务”("Create Basic Task" )向导没有提供必要的身份验证详细信息的字段。因此,电子邮件的发送很可能会失败。它可能会起作用,但前提是SMTP 服务器(SMTP server)不需要身份验证来发送电子邮件消息。
仅在Windows 7中有效的另一个操作是“显示消息”("Display a message"):如果您选择此任务操作(task action),您所要做的就是输入消息的标题和要显示的文本。
完成后,单击或点击Next,然后点击Finish。
结论
如您所见,在Task Scheduler中创建基本的计划任务很容易。该向导允许您选择许多关于触发任务的内容以及发生这种情况时应采取的操作的设置。如果您有任何建议、疑问或问题,请在下方给我们留言,让我们谈谈。
How to create basic tasks with Task Scheduler, in 5 steps
With the help of the Task Scheduler, you can create all kinds of automated tasks to be run by Windows. For example, you can schedule some apps to run at specific time intervals or display a message on your desktop when something happens. Unfortunately, not many people know about this tool, as Windows does not advertise it as much as it deserves. To help you get started working with it, we created this guide on how to use the basic task wizard offered by the Task Scheduler. Here is how it works:
How to access the Task Scheduler in Windows
If you want to use the Task Scheduler, you must first know how to open it. If you do not know how, we have published a separate guide on this subject: 9 ways to start the Task Scheduler in Windows (all versions).
If you do not have the time required to read that tutorial too, a fast way to open the Task Scheduler in any modern version of Windows is to use the search. Type the word schedule in Cortana's search field on the taskbar in Windows 10, on the Start screen from Windows 8.1, or in the search field on the Start Menu, in Windows 7. Then, click or tap on the Task Scheduler search result.
Before going ahead, remember that Task Scheduler looks and works the same in Windows 10, Windows 7 and Windows 8.1. Because of that and also for simplicity, we are going to use screenshots taken mainly in Windows 10.
Step 1. Start the "Create Basic Task" wizard
In the Task Scheduler window, go to the Actions column on the right. There, click or tap the "Create Basic Task" link, to open the wizard bearing the same name.
The wizard allows anyone to create basic tasks that are executed by Windows, at a given time or when a specific condition is met. To illustrate the whole process, let's assume that you want to create a task that periodically runs the Disk Cleanup tool.
Step 2. Name the task and give it a description
On the first step of the wizard, enter a name and a description for your new task. Then, click or tap the Next button.
Step 3. Choose when to execute the new task
You have to decide when the task starts. There are many options for choosing when the task is run: every day, weekly, monthly, only once, each time your computer starts, every time you log on, or when a particular event takes place. This part of the process is called the task trigger and, in other words, it is what needs to happen for the task to run. Pick the option that you want and press Next.
You must provide more details about the time when the task should run, depending on the option you have chosen previously.
For example, if you want the new task to be executed every Wednesday at 10:00 PM, you should choose Weekly and then make the following configuration:
- Set the starting date and time next Wednesday, at 10:00 PM;
- In the "Recur every" field, type 1, meaning that the task is going to be run weekly;
- Choose the day of the week as Wednesday.
If you choose to execute the task Monthly, apart from the starting date and time, you must also choose the month when the task is executed. Click or tap on the Months drop-down menu to make the task run on several specific months, in all the months of the year, or in just one month.
Then, you can choose the day or days of the month, by checking Days and typing the days, or by selecting them from the list.
You can also set the task to run on a specific day of a specific week. To do that, click or tap the On option. Then, in the first drop-down list, choose the number of the week and in the second drop-down list, pick the day of the week.
After you are done setting when the task is going to be executed, click or tap Next.
Step 4. Set the action that you want to be executed
On the next step, you must tell Task Scheduler the action to take: "Start a program," "Send an e-mail" or "Display a message."
Here, there is an essential difference between Windows 10 and Windows 8.1 on the one hand, and Windows 7, on the other hand. The three options are available in all these Windows versions, but the last two are highlighted as deprecated in Windows 10 and Windows 8.1, which means that they do not work in these operating systems.
Even if you can follow the wizard and create a task that sends an e-mail or displays a message, just before the task is saved, you get an error message like the one below, which states that "The task definition uses a deprecated feature."
Therefore, in Windows 10 and Windows 8.1, you cannot create tasks that send e-mails or display messages, even if the wizard displays these options. You can create such tasks only in Windows 7. If you want to see how they work, read the last section of this guide.
However, let's continue the tutorial and see how to set the action that is going to be executed by the task:
If you want to run a program like Disk Cleanup, select "Start a program" and then click or tap Next.
Click or tap Browse, select the program or the script that you want to be run, and then press Open. Alternatively, you can also type the location to the executable file of that program. If you want or need, you can add arguments and set the folder where the program/script starts. When you are done, press Next.
Step 5. Check the details of the new task and save it
Finally, you can see a summary of the task and the settings that you have made. Click or tap the Back button if you want to change anything. Otherwise, press the Finish button. This action saves the task and enables it to be run when you scheduled it.
How to use Task Scheduler to create tasks that send e-mails or display messages (only in Windows 7)
If you are using Windows 7, let's see how to set a "Send an e-mail" action:
After you choose to use this action and press the Next button, you have to enter the details of your message: sender, receiver, email subject and the text content. If you want, you can also attach a file. The last and most important step is providing the address of the SMTP server that sends the email. You should use the SMTP server of the email address you specified in the From field. However, the trouble is that most SMTP servers require authentication before sending anything, to prevent abuses and problems. The "Create Basic Task" wizard has no fields for providing the necessary authentication details. Therefore, the sending of the email is more than likely going to fail. It might work, but only if the SMTP server does not require authentication for sending email messages.
The other action that only works in Windows 7 is the one called "Display a message": If you choose this task action, all you have to do is type the title of the message and the text that you want to be displayed.
When done, click or tap Next and then Finish.
Conclusion
As you can see, creating basic scheduled tasks is easy in Task Scheduler. The wizard lets you choose many settings about the what triggers the task and what actions it should take when that happens. If you have any suggestions, questions or problems, leave us a comment below and let's talk.