I want to be able to run cmd.exe from a Python script and a particular command with arguments but I can’t seem to get it working.
I have tried
cmdL = r"C:\WINDOWS\system32\cmd.exe"
schTasks = "schtasks.exe"
#run the schtasks.exe
os.system(cmdL + schTasks)
but the dos window appears and then disappears quickly.
What am I doing wrong?
Thanks
The modern way of executing processes from a Python script is by using the subprocess module:
You can also pass arguments, for example:
This means you won’t need to utilize
cmd.exe. Python will execute the given executable with the given parameters as desired.