Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
735 views
in Technique[技术] by (71.8m points)

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

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

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

D:pys1.py
D:pys2.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:python27python.exe) at the same time.

Thank you

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Method 1: Bat file.

If you have python in the PATH Environment variable:

start python D:pys1.py
start python D:pys2.py

Else literal path

start C:python27python.exe D:pys1.py
start C:python27python.exe D:pys2.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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...