如何在窗口 xp / 7 中从批处理文件调用/运行多个 python 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13880650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 09:49:17  来源:igfitidea点击:

how to call / run multiple python scripts from batch file in window xp / 7

pythonbatch-filescheduled-tasks

提问by JPC

I'm trying to schedule run multiple pythons using batch file.

我正在尝试使用批处理文件安排运行多个 python。

For example there are my python files that I want to schedule run them on the daily basis

例如,我想安排我的 python 文件每天运行它们

D:\py\s1.py
D:\py\s2.py

now how can I combine these two files into a .bat, so that I can schedule run these two file using python.exe(C:\python27\python.exe) at the same time.

现在我如何将这两个文件组合成一个 .bat,以便我可以同时使用python.exe( C:\python27\python.exe)安排运行这两个文件。

Thank you

谢谢

采纳答案by David Ruhmann

Method 1: Bat file.

方法一:bat文件。

If you have python in the PATH Environment variable:

如果您在 PATH 环境变量中有 python:

start python D:\py\s1.py
start python D:\py\s2.py

Else literal path

其他文字路径

start C:\python27\python.exe D:\py\s1.py
start C:\python27\python.exe D:\py\s2.py

Note that this will not wait for a return from either execution. Note, do not forget to add quotations around the path strings if they contain spaces or special characters.

请注意,这不会等待任一执行的返回。请注意,如果路径字符串包含空格或特殊字符,请不要忘记在它们周围添加引号。

See start /?for more help and options.

查看start /?更多帮助和选项。

Method 2: Two different Scheduled Tasks

方法二:两个不同的计划任务

Create two separate scheduled tasks that start at the same time each calling python to run one of the scripts.

创建两个同时启动的独立计划任务,每个任务都调用 python 来运行其中一个脚本。