If I have a batch file creating a scheduled task, and it gets run multiple times, I'd like to have it just ignore subsequent attempts to create the task. I'm aware of the /F parameter that forces the task to be created, thus overwriting an existing task, but I'm wondering if there's an equivalent option to suppress the warning but NOT overwrite the task.

For example, if you run this twice:

SCHTASKS /CREATE /SC ONLOGON /TN "Test" /TR "notepad.exe"

The second time you get prompted:

WARNING: The task name "Test" already exists. Do you want to replace it (Y/N)?

Is there a way to suppress that prompt or answer N? I tried this:


But I get an error (which doesn't make sense to me):

ERROR: Invalid input. Valid values are (Y|N).

Is this a valid solution, can this error be safely ignored? Or should I do something else?

| improve this question | | | | |
  • Same error comes up. Perhaps I just needn't worry about it. – therks Dec 10 '19 at 7:57
  • That would overwrite an existing task. If you fully read my post (or at least the title) you'd see I specifically don't want to use the /F parameter. – therks Dec 10 '19 at 9:32

You can try this:

<nul set /p="N" | SCHTASKS /CREATE /SC ONLOGON /TN "Test" /TR "notepad.exe"

This pipes N to the command without echoing a newline.

| improve this answer | | | | |
  • There we go. I knew there had to be a way to do it. So I guess echo was outputting a line break, and that's what was causing the error to appear? – therks Dec 10 '19 at 9:35
  • Yes, you are right! – Wasif Hasan Dec 10 '19 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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