Selectively deleting system scheduled tasks

Windows 7 box has a list of scheduled tasks - > Default Windows tasks + Certain custom tasks that all start with a certain string. Previous code deleted all tasks with the command:

schtasks /Delete /TN * /F

Instead we want to retain the default Windows tasks, and selectively delete the tasks that start with a certain string say abctask1, abctask2. How to proceed further? Thanks!


Assuming your tasks are one word (e.g., abctask1, abctask2 - not "abc task 1"), this should work:

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

If you want wildcard (*) to be used in your selection of tasks to delete, try using this simple batch command:

(sample only)

echo off
del %SystemDrive%\Windows\Tasks\Google*
del %SystemDrive%\Windows\Tasks\Facebook*

I ended up here while looking for a way to automate disabling some stock Windows scheduled tasks. I could not get any of the current examples to properly handle task names with backslashes and spaces. I found that using csv format and the find command worked best for me:

for /f "tokens=1 delims=," %%x in ('schtasks /query /fo csv ^| find "\Microsoft\Windows\Application Experience\"') do schtasks /Delete /TN %%x /F