且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows计划任务和控制台应用程序

更新时间:2023-02-19 18:26:17

是的,Windows将默认启动一个新实例;但是,您可以控制此行为。在控制面板中,转到任务计划程序。查找任何时间计划任务,右键单击/属性,然后选择设置选项卡。在底部,您会看到一个名为如果任务已在运行,则应用以下规则的选项。您可以选择不启动新实例,并行运行新实例,对新实例排队,或停止现有实例。你想要的第一选择。 Windows任务计划程序API 提供相同的功能。

Yes, Windows will start a new instance by default; however, you can control that behavior. In Control Panel, go to Task Scheduler. Find any time-scheduled task and right click/Properties, then choose the Settings tab. At the bottom, you'll see an option named "If the task is already running, then the following rule applies." You can choose to not start a new instance, run a new instance in parallel, queue a new instance, or stop the existing instance. You want the first choice. The Windows Task Scheduler API provides the same functionality.