注销和登录后任务计划程序无法显示应用程序的 GUI(运行 无论用户是否登录)

Task scheduler can't show GUI of the application after logout and login (run whether user is logged on or not)

我有一个 GUI 应用程序,我希望它在 reboot/logout windows 计算机后自动 运行。

下面是我如何使用 windows 任务调度程序:

  1. 首先运行创建任务的命令:c:\Windows\System32\schtasks.exe /Create /TN taskname /XML taskname.xml /RU用户名/RP 密码/IT

  2. 创建任务后, 在常规选项卡中,选择了 "Run whether user is logged on or not" 单选按钮,但未选中 "Do not store password" 复选框。 在触发器选项卡中,我设置为每 5 分钟重复一次任务。

重新启动计算机后,它可以自动触发应用程序 运行 并在 5 分钟内显示 GUI。但是,如果我注销再登录电脑,它只会触发app 运行 而没有显示GUI,我已经等了大约10分钟,我只能看到app的进程是 运行 在任务管理器中。除非我手动结束任务然后 运行 任务,否则它将 运行 具有 GUI 的应用程序。

有谁知道为什么会这样以及如何解决?

谢谢,

这似乎是最近版本的 Windows' TaskScheduler 的方式。

根据Microsoft(重点添加):

You can specify that a task should run even if the account under which the task is scheduled to run is not logged on when the task is triggered. To do this, select the radio button labeled Run whether user is logged on or not . If this radio button is selected, tasks will not run interactively. To make a task run interactively, select the Run only when user is logged on radio button.

本质上,如果你 select 'Run whether user is logged on or not',进程将不会启动 UI。