运行 可见应用程序,使用 Java ProcessBuilder,来自 TaskScheduler 启动的进程

Running visible applications, using Java ProcessBuilder, from a process started by TaskScheduler

众所周知,在 Windows 的最新版本中通过 TaskScheduler 启动任务时,如果任务是 "run whether user is logged on or not",则任务不会 运行 交互 - 即它会不开始 UI.

供参考,这是根据Microsoft, and has been highlighted in this SuperUser question and this :

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.

但是,我的问题是由此衍生出来的。

我不确定为什么会这样,但实际上我正在尝试解决是否有解决方法 - 例如可以添加一些环境变量或属性以使(不可见的)客户端启动可见进程。

有什么想法吗?

因此,我找到的解决方法是停止使用 TaskScheduler,而是创建一个脚本来启动我的应用程序,并在开始菜单 > 程序 > 启动文件夹中添加该脚本的快捷方式。

归功于 HowToGeek 上的这篇文章:

On Windows 7 and earlier versions of Windows, the Start menu contained a “Startup” folder to make this easy.

This folder is no longer as easily accessible on Windows 8, 8.1, and 10, but it’s still accessible. To access it, press Windows Key + R, type “shell:startup” into the Run dialog, and press Enter.

Shortcuts you add to the “shell:startup” folder will only launch when you log in with your user account. If you’d like a shortcut to launch itself whenever any user logs in, type “shell:common startup” into the Run dialog instead.

因为我希望我的应用程序在系统启动时启动,而不是用户登录,所以我使用了“shell:common startup”link.

以这种方式启动的应用程序 - 或者在我的例子中,由以这种方式启动的应用程序启动的应用程序 - 可见 and/or 通过其 UI 进行交互。