Windows Run Scheduled Task After Wake Up with Command Line

2

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: http://technet.microsoft.com/en-us/library/cc772785%28v=ws.10%29.aspx#BKMK_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.

Oliver Spryn

Posted 2013-06-28T13:49:08.583

Reputation: 269

@frequency Have you tried the GUI to verify the settings of the task itself? – Ramhound – 2013-06-28T14:06:50.057

@Ramhound This scheduled task needs to be created and run by an automated script, so I couldn't use the GUI. – Oliver Spryn – 2013-06-28T14:16:51.470

I didn't ask you to create it through the GUI I asked you verify the settings for the task itself. – Ramhound – 2013-06-28T16:01:02.673

Answers

1

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".

Brian

Posted 2013-06-28T13:49:08.583

Reputation: 8 439