查看计划任务
schtasks
schtasks /query
视图模式详细信息
schtasks /query /v
schtasks /query /v /fo list
逗号分隔列表
schtasks /query /v /fo csv
逗号分隔列表,不显示标题。
schtasks /query /v /fo csv /nh
schtasks /query /v /fo /nh
schtasks /query /v /fo csv /nh
C:\>schtasks /query /s 169.254.100.225 /u administrator /p windows
INFO: There are no scheduled tasks present in the system.
使用/create参数创建计划任务
每24小时
schtasks /create /tn Mytask /tr notepad.exe /sc hourly /ru zly /rp windows
指定每12小时
schtasks /create /tn mytask /tr notepad.exe /sc hourly /ru zly /rp windows /mo 12
schtasks /create /tn mytask /tr write.exe /sc hourly /ru zly /rp windows /mo 23 /sd 2008/09/09 /ed 2009/09/09 /st 20:00:00
C:\>schtasks /create /tn Mytask /tr notepad.exe /sc hourly /mo 12 /st 08:00:00 /
sd 2007/07/07 /ed 2007/08/09 /ru zly /rp windows
SUCCESS: The scheduled task "Mytask" has successfully been created.
C:\>schtasks /delete /tn Mytask /f
SUCCESS: The scheduled task "Mytask" was successfully deleted.
每30天
C:\>schtasks /create /tn Mytask /tr mmc.exe /sc daily /mo 30 /sd 2007/02/28 /ed
2007/12/31 /st 20:00:00 /ru zly /rp windows
每30个周
C:\>schtasks /create /s 169.254.100.225 /u administrator /p windows /tn RemoteTe
st /tr notepad.exe /sc weekly /mo 30 /ru administrator /rp windows
SUCCESS: The scheduled task "RemoteTest" has successfully been created.
每50个周
C:\>schtasks /create /tn Mytask /tr "%systemdrive%\internet explorer\iexplore.ex
e" /sc weekly /mo 50 /sd 2007/08/09 /ed 2007/08/10 /ru zly /rp windows
任务在指定的日期和时间运行一次
C:\>schtasks /create /tn Mytask /tr notepad.exe /sc once /st 20:00:00 /sd 2007/
9/09 /ru zly /rp windows
任务在每次系统启动的时候
C:\>schtasks /create /tn Mytask /tr notepad.exe /sc onstart /ru zly /rp windows
每当用户(任意用户)登录的时候
C:\>schtasks /create /tn Mytask /tr notepad.exe /sc onlogon /ru zly /rp windows
在空闲的10分钟时候运行一个屏保称序。
C:\>schtasks /create /tn Mytask /tr "%windir%\system32\logon.scr /s" /sc onidle
/i 10 /ru zly /rp windows
把上面的scheduled---改变一个任务的称序和账户(administrator)
C:\>schtasks /change /tn Mytask /tr write.exe /ru administrator /rp xxxxxx
改变一个任务称序和账户(system)注意受限账户既便更改到system账户任务也无法运行,请参阅组策略-用户的权利分配。只有administrators组(默认)
C:\schtasks /change /tn Mytask /tr write.exe /ru system
运行一个任务
C:\schtasks /run /tn Mytask
结束一个任务
C:\schtasks /end /tn Mytask
删除全部的任务
C:\schtasks /delete /tn * /f
立即运行和终止远程计划任务
C:\>schtasks /run /s 169.254.100.225 /u administrator /p windows /tn remotetest
SUCCESS: Attempted to run the scheduled task "remotetest".
C:\>schtasks /end /s 169.254.100.225 /u administrator /p windows /tn remotetest
SUCCESS: The scheduled task "remotetest" has been terminated successfully.
忘了空密码默认无法运行计划任务,想空密码运行计划任务,gpedit.msc-本地策略-安全设置-使用空白密码的本地帐户只允许进行控制台登录禁用。启用禁用如果不设密码可能会带来安全隐患。