[英]Multi-line Command Prompt Command
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.