Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Agendamento online, or online scheduling, refers to the process of setting up tasks to run automatically at specified times or intervals. In the Windows environment, this is typically achieved using the Task Scheduler, a built-in utility that allows users to automate tasks on a computer. This article will guide you through the process of scheduling tasks using both the graphical interface of Task Scheduler and the command line via Command Prompt and PowerShell.
Using Task Scheduler GUI
Open Task Scheduler:
Win + R
to open the Run dialog.taskschd.msc
and press Enter.Create a Basic Task:
Define Task Actions:
Finish and Save:
Using Command Line
Using Command Prompt:
To create a scheduled task using the Command Prompt, use the schtasks
command. Here is an example:
schtasks /create /tn "MyTask" /tr "C:\Path\To\YourScript.bat" /sc daily /st 09:00
/tn
: Specifies the task name./tr
: Specifies the task action, such as running a script./sc
: Specifies the schedule frequency (e.g., daily, weekly)./st
: Specifies the start time.Using PowerShell:
PowerShell provides more flexibility and scripting capabilities. Here is an example of creating a scheduled task using PowerShell:
$action = New-ScheduledTaskAction -Execute "C:\Path\To\YourScript.ps1"
$trigger = New-ScheduledTaskTrigger -Daily -At 9AM
$principal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "MyTask"
New-ScheduledTaskAction
: Defines the action to execute.New-ScheduledTaskTrigger
: Defines when the task should run.New-ScheduledTaskPrincipal
: Defines the user context for the task.Register-ScheduledTask
: Registers the task with the specified settings.Examples:
To schedule a batch script to run every day at 10 AM using Command Prompt:
schtasks /create /tn "DailyBackup" /tr "C:\Scripts\backup.bat" /sc daily /st 10:00
To schedule a PowerShell script to run every Monday at 8 AM:
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File C:\Scripts\weekly_report.ps1"
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday -At 8AM
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "WeeklyReport"