How can I create a scheduled task from the command line that only runs on demand?
I"m trying to duplicate the steps in this article for creating a shortcut that launches a program without a UAC prompt. I'd like to create the task from the command line, however.
Here's the schtasks.exe command I'm using:
schtasks /create /tn MyTaskName /tr "c:\MyApplication.exe" /sc ONCE /st 00:00 /RL HIGHEST /RU BUILTIN\Administrators
The /sc
and /st
switches are tripping me up. I don't want to specify a schedule or a start time but only run the task on demand.
Solution 1:
You could always specify "/sd 01/01/1901" and have it specify the date as happening in the past. It should complain "WARNING: Task may not run because /ST is earlier than current time." for obvious reasons. But it should never actaully run without some intervention from you as it will never trigger the schedule to actaully execute.
You can't leave out the times (AFAIK) as the scheduler doesn't like that. As it is a bit counterintuitive for what the scheduler is for.