Python's Subprocess.Popen With Shell=True. Wait till it is completed

As @mikkas suggest just use it as a list here is a working example:

mainProcess = subprocess.Popen(['python', pyfile, param1, param2], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# get the return value from the method
communicateRes = mainProcess.communicate()

stdOutValue, stdErrValue = communicateRes

You are calling python.exe pyfile param1 param2

By using communicate() you can get the stdout and stderr as a Tuple

You can use python method split() to split your string to a list for example:

cmd = "python.exe myfile.py arg1 arg2"

cmd.split(" ")

Output:

['python.exe', 'myfile.py', 'arg1', 'arg2']