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.


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.

  • This may work. When I create the task from the UI, I can leave out the time but I can't seem to duplicate this from the command line. – Jason Mar 13 '12 at 16:03
  • When creating the task in the UI, how are you leaving out the time? I don't see a way to do this without specifying either a dates or one fot eh following: "when the computer starts", "when i login", or "when a specific event is logged". Maybe you are doign something different. If you are using anothe roption you should be able to specify it on the command line. – MikeAWood Mar 26 '12 at 22:17
  • Adding /sc once /sd 01/01/1901 /st 00:00 worked. It doesn't seem to work if one of those params are missing. – Molten Ice May 8 '17 at 9:55
  • /sc ONCE /st 00:00 would suffice the purpose – sactiw May 9 '17 at 15:23

Have you tried just creating the shortcut with the program & options you want to run without UAC. Then go to the shortcut's properties, Advanced, then 'Run as Administrator'?

I use this technique for a BAT file that alters ip routes for me which normally requires elevated access.

  • When I do this it still shows the UAC prompt. For our program, double-clicking the shortcut and then accepting UAC isn't the same as right-clicking and running as administrator. – Jason Mar 13 '12 at 16:06

I created an XML template, with the "Triggers" node removed.

To create a schedule task XML file:

  • In the GUI, right click on a task and choose Export.
  • At the command line...

    schtasks /query /xml /tn "Task Name" > c:\path\task.xml

To delete the Triggers and make other alterations:

  • Open the XML file in a text editor that understands UTF-16.

    notepad c:\path\task.xml

  • Delete the lines starting from through and including the line containing .

  • Save the file.

To import a task XML file, after editing it:

  • In the GUI, choose the branch where you would like to add the task, then click the Action menu and choose Import Task.
  • At the command line...

    schtasks /create /tn "Task Name" /xml c:\path\task.xml

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.