I was trying to run cmd.exe with argument ls.
I used the below code
import subprocess
subprocess.call(['C:\Windows\System32\cmd.exe', 'ls'])
After executing this cmd.exe is opening but not taking ls as input
There are two mistake in your script
ls not supported in windows use dir instead/C parameter needed to run a commandModified script is
>>> import subprocess
>>> subprocess.call(['C:\\windows\\system32\\cmd.exe', '/C', 'dir'])
Note: Use \ to escape backslash character
lsis not a recognized command in Windows.lsis not available. Why don't you use theospackage?lswork when you input it into a cmd shell ?