Windows 任务计划程序将仅运行应用程序一次

发布于 2024-09-24 23:44:11 字数 385 浏览 4 评论 0原文

所以我的情况是我正在 Windows 任务计划程序上运行一个应用程序。该应用程序每天下午 1 点运行一次。该应用程序会执行一些查询并将数据传输到 FTP 站点。所有这些都运行良好,除了周末我不在这里时,应用程序会运行并且仍然显示 GUI 供我查看。这似乎使它停止在调度程序上运行,直到我关闭应用程序。因此,周六它将运行,并且该应用程序将继续显示,以便我在周一回来时查看。但在周日,当调度程序尝试再次运行它时,它将失败,因为应用程序尚未关闭。

首先让我确认这就是任务计划程序应该如何工作的。其次,我有哪些替代方案可以安排每天运行并保持 GUI 显示以便我可以查看。该应用程序可以多次运行,因为每个会话不会干扰其他会话。因此,如果我去度假一周,我预计当我回来时,该应用程序的 7 个实例已经运行并正在等待我的审核。

谢谢 AGP

So my situation is that I am running an app on the Windows Task Scheduler. This app is run once a day at 1pm. the app does some queries and transfers data to an FTP site. All that is working great except on the weekends when i am not here the app is run and the GUI is still displayed for me to review. This seems to make it stop running on the scheduler until I shut down the app. So on Saturday it will run and the app will remain displayed for me to review when I get back on Monday. but on Sunday when the scheduler attempts to run it again it will fail because the app has not been closed down.

First let me confirm that this is how the Task Scheduler is supposed to work. Second, what are my alternatives for scheduling to run every day and keep the GUI displayed so that I can review. The app can run multiple times as each session does not interfere with the other sessions. So if I'm gone for a week on vacation I would expect that when i get back that 7 instances of the app have been run and are waiting for my review.

Thanks
AGP

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

白昼 2024-10-01 23:44:11

最好的选择是消除 UI 并将消息记录到事件日志或日志文件中。如果您愿意,UI 可以作为单独的进程从 CLI 生成,但应该作为其自己的非子进程来完成。

或者,您可以运行批处理文件而不是直接运行该过程。在批处理文件中,调用“START path_to_exe”而不是 EXE。这将导致批处理文件立即“完成”,并且 exe 在其自己的进程中运行。这不是一个好的长期解决方案,但可以为您当前的问题提供一个临时解决方案。

Your best bet is to eliminate the UI and log messages to the Event Log or a log file. The UI could be spawned from the CLI as a separate process if you prefer, but it should be done so in as its own non-child process.

Alternatively, you could run a batch file instead of the process directly. In the batch file, invoke "START path_to_exe" instead of the EXE. That will cause the batch file to "finish" instantly, and the exe to be run in its own process. This is not a good long term solution, but will give you a temporary solution to your immediate problem.

末蓝 2024-10-01 23:44:11

这是计划任务系统的默认行为,因为直到应用程序实际退出时它才知道作业已完成。因此,如果您的应用程序在 24 小时后仍然打开,则将直接跳过下一次运行,因为就调度程序而言,当前运行“仍在继续”。

就我个人而言,我会重新审视您处理工作流程的方式,因为您正在设置一个难以长期管理的场景。

This is the default behavior of the Scheduled Task system, as it doesn't know that the job is complete until the application actually exits. Therefore, if your application is still open after 24 hours, the next run will simply be skipped because the current run is "still going" as far as the scheduler is concerned.

Personally I would re-visit the way that you handle your job process, as your are setting up a scenario that will be hard to manage long term.

虫児飞 2024-10-01 23:44:11

我建议写入日志文件,而不是显示任何输出和/或错误的 UI。这样,应用程序可以写入,然后退出,并且您可以在方便时查看日志。这是自动化流程中非常常见的解决方案。

I recommend writing to a log file instead of displaying a UI for any output and/or errors. This way, the application can write, then exit, and you can review the log at your convenience. This is a very common solution for automated processes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文