Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer
    
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

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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