Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use the command line to create a scheduled task that will run after I log into my account, whether it be for the first time on that day, or after resuming from sleep/hibernate and then logging in.

I found the schtasks command, and this looks very much like what I need to run a task after logon:

schtasks /create /tn TaskName /tr TaskRun /sc onlogon

After running my command, I can see my task name listed in the scheduled tasks list, but it never runs, regardless of whether I logon from a refresh restart or after resuming from sleep/hibernate. Here is my command:

schtasks /create /tn "AutohotKey Windows Logon Trigger" /tr "calc" /sc ONLOGON

Any ideas?

Thank you for your time.

share|improve this question
@frequency Have you tried the GUI to verify the settings of the task itself? – Ramhound Jun 28 '13 at 14:06
@Ramhound This scheduled task needs to be created and run by an automated script, so I couldn't use the GUI. – Oliver Spryn Jun 28 '13 at 14:16
I didn't ask you to create it through the GUI I asked you verify the settings for the task itself. – Ramhound Jun 28 '13 at 16:01
up vote 1 down vote accepted

For complex tasks it is easier to create the task in the GUI, export it as XML and then on the command line use SCHTASKS /CREATE /tn TaskName /XML xmlfile.

The event triggers in the GUI you likely want are listed as "At log on" and "On workstation unlock".

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .