2

I want to delete scheduled tasks that start with "Adobe Acrobat" eg "Adobe Acrobat 123","Adobe Acrobat 456","Adobe Acrobat 789"

schtasks /Delete /TN Adobe* /F

This command fails to find any tasks cos its literally searching for the taskname "Adobe*"

for /f %%x in ('schtasks /query ^| findstr Adobe') do schtasks /Delete /TN %%x /F

This works only for tasknames without space, eg only finds taskname if its "AdobeAcorbat123"

How can I delete all scheduled tasksnames starting with "Adobe" and containing space?

eureka
  • 143

1 Answers1

2

Try this instead:

for /f "tokens=1*" %%a in ('schtasks /query /fo list ^| findstr /r "TaskName.*Adobe"') do schtasks /delete /tn "%%b" /f

The findstr portion uses regex (regular expressions) to extract only the lines containing the strings "TaskName" and "Adobe" from the output of schtasks. This is then tokenised by for /f (see for /? for more) and the second token containing the full path to the task (including spaces) is extracted and passed to another schtasks command that deletes said task.

Karan
  • 57,289