17

I have a onstartup task that I want to automatically run, regardless of if someone is logged in or not.

I've set it up as Run whether user is logged in or not, Do not store password1, and Run with highest privileges, which I assume would work, using the below code:

schtasks /create /tn "My OnStartup Task"  /TR "powershell blah.ps1" /sc ONSTART /f /NP /RL HIGHEST

After enabling task scheduler history, I'm getting errors like:

Event ID: 104: Task Scheduler failed to log on "<Task Author>" . Failure occurred in "LsaLogonUser" . User Action: Ensure the credentials for the task are correctly specified. Additional Data: Error Value: 2147943711.

Event ID: 311: Task Scheduler failed to start Task Engine ""  process due to an error occurring in "LUAIsElevatedToken" . Command="taskeng.exe" . Additional Data: Error Value: 2147943711.

Event ID: 101: Task Scheduler failed to start "\My OnStartup Task" task for user "<Machine>\<Task Author>". Additional Data: Error Value: 2147943711.

I've specifically set not to store the password, yet the errors are saying it's trying to use the password. I recall reading somewhere that not the storing the password checkbox also counts for "do not run interactively", or something. Could someone point me into the right direction here?

2 Answers 2

15

You should not be specifying a user account under which to run the task if you do not want to save the password. Run it as system if that would work or save the user account and password with the task.

1
  • 2
    Thanks for that Greg, I went through the permutations of flags and user (none, local, system), and found the system user actually lets it run. Thanks :)
    – glasnt
    Apr 23, 2012 at 0:46
2

My solution (noted here to give others help in addition to the accepted answer):

The task used to run under a local user. Run whether user is logged or not ticked; Do not store password not ticked.

Everything was OK until we renamed the machine - I then had to reassign the user which the job runs under to be the same user - but under a different computer.

You must log in to answer this question.

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