I have a python script which I want to run from the Windows CMD.
However, I need to open 30 such CMDs and run this same python file from all these CMDs. (Hence, going with a batch file)
Basically, I want to achieve teh foll:
- Create a batch file
- Open a cmd and run this file
- This script should open 30 other CMDs.
- Each and every CMD should execute this same python script.
How do I achieve this?
CodePudding user response:
You could get the effect that you want by creating a relatively simple script: I haven't tested it on a windows machine, so I would test it and debug, but this will give you the broad strokes:
The paths below are relative, so this script will need to be in the same directory as your server and your client.
py %%~dp0\server.py
for /l %x in (1, 1, 30) do{
py %%~dp0\client.py
}
CodePudding user response:
The following seems to satisfy my requirement:
for /l %%x in (1, 1, 30) do (
start cmd /c "python <script_name>.py"
)