Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I can create a task from command line like this:

schtasks /create /tn SomeTask /tr "do.bat arg1 arg2" /sc ONCE /st 00:00:00 /sd 01/01/1991

and now I need to delete it. However the command needs to be confirmed and I don't know how to do that from BATCH file (bat/cmd).

C:\> schtasks /delete /tn ContextSwitchTask
WARNING: Are you sure you want to remove the task "ContextSwitchTask" (Y/N)?

C:\> echo Y | schtasks /delete /tn ContextSwitchTask
WARNING: Are you sure you want to remove the task "ContextSwitchTask" (Y/N)? Y
ERROR: Invalid input.
Type "SCHTASKS /DELETE /?" for usage.

Question: How to delete scheduled task and force yes?

share|improve this question

1 Answer 1

up vote 6 down vote accepted
C:\> schtasks /delete /tn ContextSwitchTask /f
share|improve this answer
    
thanks, I totally missed that :) –  Tomas Mirezko Oct 8 '11 at 10:54
    
Doesn't exist on XP, 2003: msdn.microsoft.com/en-us/library/windows/desktop/… –  Gringo Suave Nov 10 '12 at 23:11
    
also echo Y | schtasks doesn't work. :/ –  Gringo Suave Nov 10 '12 at 23:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.