BAT Windows定时指定任务


任务计划程序:

Windows + R / taskschd.msc

1.可在面板根据需要添加定时任务:Link

2.根据 schtasks 命令添加,按需配置

schtasks /create /sc  /tn  /tr  [/s  [/u [\] [/p ]]] [/ru {[\] | system}] [/rp ] [/mo ] [/d [,...] | *] [/m [,...]] [/i ] [/st ] [/ri ] [{/et  | /du } [/k]] [/sd ] [/ed ] [/it] [/z] [/f]

2.1.每天执行命令

schtasks /create /tn "Cust.Task1" /tr c:\apps\myapp.exe /sc daily /st 07:00:00

2.2.删除命令

schtasks /create /tn "Cust.Task1"

2.3.查看定时任务列表

schtasks

2.4.立刻运行定时任务

schtasks /run /tn "Cust.Task1"

2.5.如果需要给服务器添加定时任务,需要指定:/s /u /p

Reference:

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-delete

bat