3
1
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?
Same error comes up. Perhaps I just needn't worry about it. – therks – 2019-12-10T07:57:23.193
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 – 2019-12-10T09:32:47.507