How to Create and Schedule Custom Tasks on Windows 10

On
Laptop on a tableIf you're an avid Windows user, you may have noticed that few essential and important applications like an antivirus automatically starts on the system boot up. These applications are configured as custom tasks to run automatically when a specific condition or conditions are met. As a regular Windows user, if you want to run select applications at certain conditions, you can create and schedule such custom tasks quite easily. The following guide will help you master the process of creating custom tasks on a Windows 10 PC. During the initial learning phase, use a simple application that runs for a short period of time and doesn't consume much system resources. Later on, you can easily experiment with the scheduling of full-fledged applications with complex startup trigger conditions. After getting familiar with the custom task creation process, resist the temptation of scheduling too many applications during the system boot up because it may put an additional burden on the PC and may slow down the computer, significantly.

Laptop on a table Before you start creating custom tasks on your Windows machine, I'll strongly advise against scheduling of untrusted or suspicious applications because of privacy and security concerns.

Pro Tip: Task scheduling is NOT a fun or entertainment process. Create a custom task only and only when it is really necessary.

Let's get started and learn the art of creating both basic and advanced tasks to automate important jobs and our daily workflow.

Configuring and Scheduling a Basic Task

We'll start with creation and scheduling of a basic task to get familiar with the entire concept. For simplicity's sake, we'll create a very simple job that'll automatically open an instance of Notepad editing program whenever a user logs in to his account.

Though this custom task doesn't do anything substantial, we're picking it to keep things simple and to make you familiar with the entire task creation process.

To get started, press the Windows + S key and type schedule in the search box as shown below.

Starting task scheduler from Windows search Click the Task Scheduler option to kick start the process. Once the task scheduler is in an open state, click Create Basic Task... to start the automated job creation process.

Basic task creation option within Windows task scheduler At this stage, you'll get a task creation wizard with all the options you can configure as per your requirements. If you find some options marked as deprecated, I'll advise you to avoid them to ensure your custom task remains stable and does not break in the long run.

Name and description of a custom task Start with giving a meaningful name and description to the custom task. It'll help in identifying the task from within the list of tasks if you ever want to edit or delete it in the future.

Trigger conditions for a custom scheduled task Pressing the Next button brings the Trigger tab where you can configure the condition that'll start the scheduled task, automatically. For our demo example, we've chosen the log in condition.

There are other trigger conditions as well which are briefly discussed below.

Daily/Weekly/Monthly - These trigger conditions are pretty straightforward. Select the duration upon which you want to execute the task in a recurring fashion.

One time - This trigger condition is dead simple. If you want to run a task just once on a specific date and time, then choose this option.

When the computer starts - Use this trigger condition if you want to run a task every time the computer boots up. You may note that it's different from the login condition. This condition is generally used for running background tasks in an advanced mode.

When a specific event is logged - The last one can be used to start a custom task whenever a specific hardware or software event is successfully logged by Windows. It's an advanced trigger which requires some system knowledge.

Action configuration for a Windows custom task After configuring the trigger condition, it's time to choose the primary action that must be executed whenever the condition is fulfilled.

Two of the deprecated options (as shown above) should be ignored to ensure long-term stability of the custom task. The only option left is the ability to run an application program.

Application program selection for a custom task The next screen is where you actually select the program that much be executed upon trigger fulfillment. To match our demo example discussed earlier, I've selected the Notepad application.

The other 2 options available on this screen are as follows.

Add arguments (optional): If required, you can use this field to pass the parameters (arguments) to the application. For example, if you want Notepad to open a specific file by default, you can supply that file name in this field.

Start in (optional): This second option field can be used to specify the directory in which the program should start. For example, if you're specifying the file name in the first optional field, here you can specify the directory path where that file resides.

Completion dialogue for a custom Windows basic task And, the finishing screen gives you a chance to review all the settings of the configured task. Upon review, if you find something different from what you desire, feel free to go back to modify and edit the task options.

You can create this example task on your Windows system and can log in after a reboot to see if the Notepad application starts automatically or not. Make sure to delete all the tasks you're creating for the learning purpose.

Configuring a Custom Task in Advanced Mode

Now that we're familiar with the basic task creation process, let's check out the advanced mode of the same which gives you more flexibility and power.

Unlike a simple task created in the previous section, we'll create a bit complex task that'll really do something meaningful. This task will permanently delete all the files residing in a specific directory and that too on the first Monday of every month.

We'll use the CCleaner application to purge the files through this custom task. Let's get started.

General task settings in Windows 10 task scheduler Open the task scheduler in the same way as mentioned at the beginning of the previous section. This time, click the Create Task... option to open the task configuration wizard in an advanced mode.

On the General tab, once again provide a name and the description for the custom task. Here, I've also selected an option that ensures the task will only run when a user has logged into his account.

If you want that the task should run without any fail, it's a good idea to check the Run with highest privileges option. You may also note that I've instructed the task scheduler to configure this task for Windows 10.

It ensures that the task will be optimized (if required) for the selected platform and will run smoothly without any compatibility issues.

The Hidden option (see above) is deselected because we do not want the application to run in the background in a hidden mode. It's because the task needs to interact with the user for the confirmation of file deletion.

Creation of a hidden task in task scheduler If your scheduled task is non-interactive in nature and monitoring its progress while running is not an important issue, you may want to run it in the background in a hidden mode.

To do that click the Change User or Group... option and select the SYSTEM account. Thereafter, you can select the Hidden option.

Do not configure the Hidden setting for our file deletion demo task as it is interactive in nature.

Trigger condition for the advanced task Now coming back to our demo task, let's move ahead. After completing the General settings, switch to the Triggers tab. Here, click the New... button to configure the trigger condition for our custom task.

This action will open the trigger editing dialogue box where you can start with On a schedule option to configure the primary execution condition for the task.

Here select all the months and the first Monday (see above) to ensure our task runs on the first Monday of every month throughout the year.

The other key trigger conditions worth mentioning here are computer lock/unlock event and the connection or disconnection of a user session.

Both these conditions are self-explanatory and can be used as per your needs and requirements. The other Advanced settings available are related to task's recurring nature, its delay in execution, its duration, and its expiration time.

Action configuration for the advanced task And now comes the configuration of our primary task that'll purge files located in a specific directory. To do that, we'll start the CCleaner program with the required parameters as shown below.

C:\Program Files\CCleaner\CCleaner.exe /DELETE "F:\CipherFiles\*.*" /METHOD "0-3"
If you carefully look at the command given above, you can easily deduce that the directory (imaginary) from where the files need to be purged is F:\CipherFiles\ and each file will be shredded and filled with junk data for up to 3 times to make them irrecoverable.

Note: For demo purposes, you can choose a different directory name and its path.

To add this job to our custom task, switch to the Actions tab and click the New... button. Here, you can first select the CCleaner executable file through the Browse... button. Now, you just need to pass the required arguments to the CCleaner program to complete the configuration.

To do that, copy the /DELETE "F:\CipherFiles\*.*" /METHOD "0-3" parameters and paste it into the Add arguments (optional): field.

Although we've already provided the full directory path within the arguments, still it'll be a good move to provide the directory location F:\CipherFiles within the Start in (optional): field.

It'll ensure that the program starts within the specified directory and purges the files without any accessibility issues.

Additional trigger conditions for the custom task There's another Conditions tab which enables you to further fine-tune the behavior and the execution schedule of the custom task.

You may note (see image above) that I've selected two conditions for this specific task. The first one ensures that the purging process will only start if the computer is in an idle state for at least 5 minutes.

And, the second condition makes sure that the task execution will only start when the computer is on AC power. The question here arises is that why I've selected these two conditions?

Well, the reason is quite simple. Multi-pass file purging is a resource consuming task with high disk activity. It's always a good move to run this task when the computer is idle. High disk activity can drain the battery power very quickly on older systems. It's always advisable to run such tasks on AC power.

Settings to fine-tune the behavior of the scheduled custom task The Settings tab gives you enough power to add more attributes to the scheduled custom task. In our example, I've enabled the option to execute the task on a manual basis, whenever such a need arises.

The second option ensures the files are purged at the earliest even if the schedule is missed for whatever reasons.

The last two options selected on this tab broadly ensure that the task does not run continuously for an indefinite period and stops without any issues on manual intervention. Feel free to experiment with the options present on this tab.

Creating Custom Scheduled Tasks from the Command Line

If you love the command line environment over a graphical interface, use the SchTasks command to create and schedule custom tasks in a geeky way. If you're not familiar with the command line environment, I'll advise sticking with the regular task scheduler discussed in the previous sections.

To get started, first you need to open the command prompt with admin privileges. To do so, press the Windows + X key and click the Command Prompt (Admin) option from the context menu.

Let's create the same basic task configured earlier which simply opens the Notepad editing program whenever a user logs in to the system. Here's how to create it directly from the command line.

SchTasks /Create /SC ONLOGON /TN "Notepad on Logon" /TR "C:\Windows\System32\notepad.exe"
The /Create switch obviously creates a new task. The /SC is the task scheduling switch where we've supplied the value ONLOGON to execute the program on user login.

The other values that /SC switch can accept are viz., ONCE, ONIDLE, MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONEVENT.

The /TN switch is used to give the task a name to distinguish it from others in a list of scheduled tasks. Just give an appropriate name to the task surrounded by double quotes.

The important /TR switch is used to configure the action associated with the task. In other words, here you can provide the command you want to run at the scheduled time. In our example, we're running the Notepad editing program.

Now, let's create a slightly complex task where all the files located in a specific directory are automatically purged on the 1st day of every month. Here's how to do it from the command line.

SchTasks /Create /SC MONTHLY /M * /D 1 /TN "Purge Confidential Files" /TR "C:\Program Files\CCleaner\CCleaner.exe /DELETE 'F:\CipherFiles\*.*' /METHOD '0-3'"
Here you can find 2 new switches used in the command. Let's understand them one by one.

First of all, you may note that now the /SC switch value is MONTHLY instead of ONLOGON. In other words, we're going for the monthly execution schedule for this task.

The new switch /M gets the value * which is a wildcard character. It means that the task should be executed in all the 12 months.

The /D switch with the value 1 denotes the first day of the month. Both these new switches ensure that the file purging task is executed on the first day of all the 12 months.

The last thing that needs your attention is the action command for the /TR switch. Here, you may note that the values for the /DELETE and /METHOD switches are enclosed in single quotes.

We have to do so because the entire action command in itself is enclosed within double quotes and using the same for the parameter switches will break the task scheduling command.

Best Practices for Custom Task Scheduling

Now that we're familiar with the custom task scheduling process on Windows 10, let's once go through the guidelines and best practices to avoid any undesirable conditions that may arise due to the incorrect usage of the same.

Following are some of the basic guidelines for task creation and scheduling.

  • Do not create custom tasks until it is absolutely necessary and there is no alternate way to do it.
  • If you're not fully aware what exactly the task will do, kindly do not create it.
  • If the task is a resource hogging process, configure the conditions where it should terminate automatically if running for a longer period.
  • If a task is going to access sensitive information stored on your computer, try not to create it in the first place and go for the manual execution of the same.
  • Start with simple tasks during the learning phase and gradually shift to more complex tasks.
Hopefully, this guide will help you automate the daily tasks in an efficient way to increase your productivity.