Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Scheduled tasks, known as "Tarefa Agendada" in Portuguese, are a crucial feature in Windows that allows users to automate tasks, such as running scripts or launching applications at specified times or events. This functionality is managed through the Windows Task Scheduler, a built-in tool that provides a graphical interface, as well as through command-line tools like schtasks.exe
and PowerShell cmdlets.
Examples:
Using Task Scheduler GUI:
To create a scheduled task using the Task Scheduler GUI, follow these steps:
Using Command Line with schtasks.exe
:
The schtasks.exe
command allows you to create, delete, and manage scheduled tasks directly from the command line. Here's how to create a simple task that runs a script daily:
schtasks /create /tn "DailyScript" /tr "C:\Path\To\YourScript.bat" /sc daily /st 09:00
/tn
: Task name./tr
: Task run path (script or program to execute)./sc
: Schedule type (e.g., daily, weekly)./st
: Start time.Using PowerShell:
PowerShell provides a more flexible way to manage scheduled tasks with the New-ScheduledTask
and Register-ScheduledTask
cmdlets. Here's an example of creating a scheduled task with PowerShell:
$action = New-ScheduledTaskAction -Execute "C:\Path\To\YourScript.ps1"
$trigger = New-ScheduledTaskTrigger -Daily -At 9AM
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "DailyScript" -Description "Runs a PowerShell script daily at 9 AM"
New-ScheduledTaskAction
: Defines the action to perform.New-ScheduledTaskTrigger
: Defines the trigger for the task.Register-ScheduledTask
: Registers the task with Task Scheduler.