I'm trying to create a script where it opens command prompt and navigates to a folder to run a batch job.
import subprocess
import os
import sys
subprocess.Popen(['start', 'cmd', '/k',
'cd/Program Files/PremiumSoft/Navicat Premium'
& 'navicat.exe -batchJob testJob'])
The two commands run fine independently but I'm not sure how to put them together and run them in the same script.
如果你想在一个进程中运行多个命令,你将有可能运行subprocess.Popen
与shell
设置为参数True
:
subprocess.Popen('startcmd/kcd/Program Files/PremiumSoft/Navicat Premium&navicat.exe -batchJob testJob', shell=True)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.