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:
ECHO N|SCHTASKS /CREATE /SC ONLOGON /TN "Test" /TR "notepad.exe"
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?