任务计划程序如何运行 exe 的多个实例?
任务计划程序如何运行 exe 的多个实例? 假设我每天都有打开 notepad.exe 的计划 我希望每天都能打开一个新的,而不是只打开第一个。
如果我首先运行 .bat 来运行 exe,控制台窗口将短暂出现,然后我需要某种方法来不显示任何控制台窗口。
请帮忙
How can Task Scheduler run multiple instances of the exe?
Let's say I have a daily schedule to open notepad.exe
I hope each day will open a new one, instead it will only open the first one.
If I first schdule run a .bat to run the exe, a console window will appear briefly, then I need some way to not show any console window.
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你在什么操作系统上尝试这个?我使用您的 notepad.exe 示例(无 .cmd,仅启动 notepad.exe)在 Windows Server 2008 R2 上对此进行了测试。如果我在任务设置中设置选项“如果任务已在运行,则应用以下规则:”>>并行运行一个新实例。
如果我选择此选项,则每次计划任务运行时都会启动一个新的 notepad.exe,否则只有第一个任务启动它。
/edit:
对于 Windows XP,您可以从另一个将退出的进程启动可执行文件。正如 Ryan 提到的,您可以使用 .cmd 批处理文件和 START 命令。如果您不希望登录的用户看到它运行,您可以将任务设置为以 NT AUTHORITY\SYSTEM 身份运行
What OS are you trying this on? I tested this on Windows Server 2008 R2 using your notepad.exe example (no .cmd, just launching notepad.exe). If I set the option in the task Settings "If the task is already running, then the following rule applies:" >> Run a new instance in parallel.
If I select this option then a new notepad.exe launches each time the scheduled task runs, otherwise only the first one launches it.
/edit:
For Windows XP, you could launch the executable from another process that will exit. As Ryan mentioned, you could use a .cmd batch file and the START command. If you don't want the user that's logged in to see it run, you could set the task to run as NT AUTHORITY\SYSTEM
如果批处理文件编写正确,那么控制台窗口应该只显示几分之一秒,然后消失。
这应该不是问题,特别是因为计划任务的主要原因是在没有人监视计算机时运行任务。
如果控制台窗口的瞬间出现确实是一种难看的反自然犯罪,那么您需要一个不会创建控制台窗口的解决方案。有关一些脚本编写建议,请参阅此超级用户线程。
或者,由于 stackoverflow 用户是程序员,您可以编写一个非常简单的 .exe 来完成您想要的操作:
If you batch file is authored correctly, then the console window should only show up for a fraction of a second, and then disappear.
This shouldn't be a problem, especially since the main reason for a scheduled task is to run things when nobody's watching the computer.
If the momentary appearance of console windows is truly an unsightly crime against nature, then you need a solution which doesn't create a console window. See this superuser thread for some scripting suggestions.
Alternatively, since stackoverflow users are programmers, you can just write a very simple .exe which does what you want: