Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Schedule Tasks in Windows Using Task Scheduler and Command Line

Scheduling tasks in Windows is a crucial skill for automating repetitive tasks, ensuring timely updates, and maintaining system health. Windows provides built-in tools like Task Scheduler and command-line utilities to help you automate tasks efficiently. This article will guide you through the process of scheduling tasks using both the graphical interface of Task Scheduler and the command line.

Using Task Scheduler

Task Scheduler is a powerful tool that allows you to create and manage common tasks that your computer will carry out automatically at the times you specify.

  1. Open Task Scheduler:

    • Press Win + R, type taskschd.msc, and press Enter.
    • Alternatively, search for "Task Scheduler" in the Start menu.
  2. Create a Basic Task:

    • In the Task Scheduler window, click on "Create Basic Task" in the Actions pane.
    • Enter a name and description for your task, then click "Next."
  3. Trigger the Task:

    • Choose when you want the task to start (e.g., daily, weekly, monthly) and click "Next."
    • Specify the start date and time, then click "Next."
  4. Action to Perform:

    • Choose "Start a program" and click "Next."
    • Browse to the program or script you want to run, or enter the path manually.
    • Click "Next," then "Finish" to create the task.

Using Command Line with SCHTASKS

For those who prefer using the command line, Windows provides the SCHTASKS utility to create and manage scheduled tasks.

  1. Open Command Prompt:

    • Press Win + R, type cmd, and press Enter.
  2. Create a Scheduled Task:

    • Use the following command to create a task:
      SCHTASKS /CREATE /TN "MyTask" /TR "C:\Path\To\YourProgram.exe" /SC DAILY /ST 09:00
    • This command schedules YourProgram.exe to run daily at 9 AM.
  3. List Scheduled Tasks:

    • To view all scheduled tasks, use:
      SCHTASKS /QUERY
  4. Delete a Scheduled Task:

    • To delete a task, use:
      SCHTASKS /DELETE /TN "MyTask" /F

Using PowerShell

PowerShell also provides cmdlets for task scheduling, offering more flexibility and scripting capabilities.

  1. Open PowerShell:

    • Press Win + R, type powershell, and press Enter.
  2. Create a Scheduled Task:

    • Use the following script to create a task:
      $action = New-ScheduledTaskAction -Execute "C:\Path\To\YourProgram.exe"
      $trigger = New-ScheduledTaskTrigger -Daily -At "9:00AM"
      Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "MyTask"
  3. List Scheduled Tasks:

    • To list tasks, use:
      Get-ScheduledTask
  4. Remove a Scheduled Task:

    • To remove a task, use:
      Unregister-ScheduledTask -TaskName "MyTask" -Confirm:$false

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.