Subprocess module in Python to cmd.exe
Question: I have some code here trying to open up the `cmd.exe` from Python and input
some lines for the command to use.

Here it is:

    
    
    PDF= "myPDF"
    output= "my output TIF"
    
    def my_subprocess(command,c='C:\here'):
         process = subprocess.Popen(command,stdout=subprocess.PIPE,shell=True,cwd=c)
         communicate = process.communicate()[0].strip()      
    
    my_subprocess('"cmd.exe" && "C:\\here\\myinfamous.bat" && "C:\\my directory and lines telling cmd to do stuff"'+ PDF + " " + output)
    

When run with the rest of my script, the command prompt does not even open up
and there seems to be no output or errors at all. My thought is that it has
not even run the `cmd.exe` command so none of this code is going in to create
the final output.

Is there something I am not doing properly?

Thank you.


Answer: You need to replace `subprocess.Popen` with `subprocess.call`

Here is a working code on windows 8 that opens a text file using notepad.
First field is the command itself and second field is argument.

You can modify these and test with your files.

    
    
    import subprocess
    
    subprocess.call(['C:\\Windows\\System32\\Notepad.exe', 'C:\\openThisfile.txt'])
    

