我需要做一个禁用所有任务的批处理文件,到目前为止我已经得到了这个:
@echo OFF
for /f "tokens=2 delims=:" %%i in ('schtasks /Query /FO LIST ^| findstr "Nombre de tarea:"') do (call :subroutine "%%i")
:subroutine
set TASKNAME=%%i
echo %TASKNAME%:%1
schtasks /change /tn=%TASKNAME%:%1 /disable
GOTO :eof
所以,我非常糟糕的grep,它已经2年没有使用它,这就是" findstr" "吐痰":
%i:" Interactivo/En segundo plano"
%i:" ADMSH-PC"
%i:" \Microsoft\Windows\Windows Media Sharing\UpdateLibrary"
所以我得到每个任务3行,而且我只需要"任务名称"对于tn属性而不是整个路径
任何帮助/提示?感谢。
答案 0 :(得分:0)
如果您要禁用所有任务,那么停止任务计划程序服务会不容易吗?
答案 1 :(得分:0)
很好,但是如果你想禁用它们,我建议把你的脚本放到vbs文件中:
您可以使用以下代码列出所有任务:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colScheduledJobs = objWMIService.ExecQuery _
("Select * from Win32_ScheduledJob")
For Each objJob in colScheduledJobs
Wscript.Echo "Caption: " & objJob.Caption
Wscript.Echo "Command: " & objJob.Command
Wscript.Echo "Days Of Month: " & objJob.DaysOfMonth
Wscript.Echo "Days Of Week: " & objJob.DaysOfWeek
Wscript.Echo "Description: " & objJob.Description
Wscript.Echo "Elapsed Time: " & objJob.ElapsedTime
Wscript.Echo "Install Date: " & objJob.InstallDate
Wscript.Echo "Interact with Desktop: " & objJob.InteractWithDesktop
Wscript.Echo "Job ID: " & objJob.JobID
Wscript.Echo "Job Status: " & objJob.JobStatus
Wscript.Echo "Name: " & objJob.Name
Wscript.Echo "Notify: " & objJob.Notify
Wscript.Echo "Owner: " & objJob.Owner
Wscript.Echo "Priority: " & objJob.Priority
Wscript.Echo "Run Repeatedly: " & objJob.RunRepeatedly
Wscript.Echo "Start Time: " & objJob.StartTime
Wscript.Echo "Status: " & objJob.Status
Wscript.Echo "Time Submitted: " & objJob.TimeSubmitted
Wscript.Echo "Until Time: " & objJob.UntilTime
Next
获取所有任务的名称,并为每个任务运行schtasks /change /tn=%TASKNAME%:%1
/ disable。
答案 2 :(得分:0)
for /f "tokens=1 delims=," %%a in (
'schtasks /Query /FO csv ^| find /V "Task name" ^| find /V "Disabled"'
) do (
schtasks /change /tn %%a /disable
)
注意:如果您显示此命令的示例“schtasks /Query /FO csv
”,我可以编辑您的语言环境的命令
答案 3 :(得分:0)
为什么禁用任务?从命令行停止并启动“任务计划”服务。如果“服务-任务计划程序”中的“停止”为灰色,请下载PsTools,然后:
以管理员身份运行:
.limit-text{
width:300px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div class="limit-text">
This is my text and I want to limit
</div>
在CMD窗口中:
PSEXEC -i -s CMD
准备就绪时:
net stop schedule
启用禁用所有计划的任务启用禁用所有任务任务计划程序停止显示为灰色