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 Create and Manage Scheduled Tasks in Windows

Scheduled Tasks in Windows allow users to automate and schedule the execution of programs or scripts at specified times or intervals. This is particularly useful for tasks that need to be performed regularly, such as backups, system maintenance, or running scripts. Windows provides several ways to create and manage scheduled tasks, including through the graphical user interface, Command Prompt, and PowerShell.

Examples:

Creating a Scheduled Task via Task Scheduler (GUI)

  1. Open Task Scheduler:

    • Press Windows + R, type taskschd.msc, and press Enter.
  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 the task, then click "Next".
  3. Trigger:

    • Choose when you want the task to start (e.g., daily, weekly, etc.) and click "Next".
    • Set the specific time and date if applicable, then click "Next".
  4. Action:

    • Select "Start a program" and click "Next".
    • Browse and select the program or script you want to run, then click "Next".
  5. Finish:

    • Review the task details and click "Finish" to create the task.

Creating a Scheduled Task via Command Prompt

  1. Open Command Prompt:

    • Press Windows + R, type cmd, and press Enter.
  2. Create a Task Using schtasks:

    • Use the schtasks command to create a task. For example, to run a script daily at 6 PM:
      schtasks /create /tn "MyDailyTask" /tr "C:\Path\To\YourScript.bat" /sc daily /st 18:00
  3. Verify the Task:

    • List all tasks to verify creation:
      schtasks /query

Creating a Scheduled Task via PowerShell

  1. Open PowerShell:

    • Press Windows + R, type powershell, and press Enter.
  2. Create a Task Using PowerShell:

    • Use the New-ScheduledTask and Register-ScheduledTask cmdlets. For example:
      $action = New-ScheduledTaskAction -Execute "C:\Path\To\YourScript.bat"
      $trigger = New-ScheduledTaskTrigger -Daily -At 6pm
      Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "MyDailyTask"
  3. Verify the Task:

    • List all tasks to verify creation:
      Get-ScheduledTask

Managing Scheduled Tasks

  • Modify a Task: Use Task Scheduler GUI or schtasks /change command.
  • Delete a Task: Use Task Scheduler GUI, schtasks /delete /tn "TaskName", or Unregister-ScheduledTask -TaskName "TaskName" in PowerShell.
  • Run a Task Manually: Use Task Scheduler GUI or schtasks /run /tn "TaskName".

Scheduled Tasks in Windows provide a robust way to automate routine tasks, ensuring they run consistently without manual intervention. Whether using the GUI, Command Prompt, or PowerShell, users have multiple options to create and manage these tasks effectively.

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.