Using python language to acces a cmd window
Question: It is possible to make a python script which opens a cmd window and enters 5
commands one by one, and after waits for an external trigger to continue
entering another 2 commands in the same window.

It is posibble? I hope You understand what I ask. PS: maybe you can share with
me a sample code or something.

Thank you in advance. M.


Answer: What i have done in the past is use Python to write a `.bat` file and run it.
And this does produce the result you describe. You can do this like that:

    
    
    import subprocess
    
    with open(r'my_bat_file.bat','w') as fout:
        fout.write('command no1')
        fout.write('command no2')
        ...
        fout.write('command non')
        fout.write('pause')
    
    subprocess.run(r'my_bat_file.bat', creationflags=subprocess.CREATE_NEW_CONSOLE)
    

The `pause` command keeps the cmd open and waiting for a key stroke. When the
key even logs, execution of the bat file will continue. If the pause is the
last line in your batch file, cmd will close.

