I have used os.system(command) in a for loop.
By using this, CMD opens, executes the command and close. For Second command, CMD opens again, executes tha command and close. Due to this, CMD pop-ups again and again.
Meanwhile, I am not able to do another task on system. I want to do this in a CMD so that i can minimize it and continue with other task.
You can just concatenate your commands, delimited by a semicolon (;) and only call os.system once.
Another approach is to write all of the command strings to a .bat or .cmd file, and then execute the resulting file with os.system.
This is more useful if the number of commands per iteration is "large-ish" and less useful if there are only a few commands per iteration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With