无论有人是否登录,我都有一个要自动运行的onstartup任务。
我使用以下代码将其设置为Run whether user is logged in or not
,Do not store password1
和Run with highest privileges
,我认为它们可以工作:
schtasks /create /tn "My OnStartup Task" /TR "powershell blah.ps1" /sc ONSTART /f /NP /RL HIGHEST
启用任务计划程序历史记录后,出现以下错误:
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.
我专门设置为不存储密码,但是错误表明它正在尝试使用密码。我记得在某个地方读到,“不存储密码”复选框也算作“请勿交互式运行”之类的内容。有人可以在这里指出我正确的方向吗?