![](/img/trans.png)
[英]How to run a python script/programs in CMD from another drive or switch drives?
[英]How to write a script to run 2 instances of CMD from shortcut and 2 python programs within (Win 10)?
我正在為 Windows 10 編寫一個 simple.bat 腳本; 我有單個部分工作,但不是全部一起工作。 基本上我想要一個 .bat 文件:
從快捷方式啟動 CMD shell,例如start "" "C:\Users............\System Tools\Command Prompt.lnk"
in that shell, go to the folder of my python file "cd C:\Users...........\myPython\
and py myFile.py %*
像第一步一樣打開一個新的 CMD (可能 position 它遠離第一個,所以它們不會重疊)
將 shell 背景顏色更改為自定義顏色(我可以使用color NN
命令的默認 colors 來完成)
對 shell 2 重復步驟 2
我沒有完全得到你想要做的事情,但你我認為你可以使用一些腳本來實現它:
例如,您可以擁有 3 個這樣的 bat 文件:
rem startboth.bat
start c:\path\to\my\folder\first.bat
start c:\path\to\my\folder\second.bat
rem first.bat
COLOR 4b
c:\Users\pnnp\Miniconda3\python.exe -v
rem second.bat
COLOR 4b
c:\Users\pnnp\Miniconda3\python.exe -m http.server
如果您單擊both.bat
,您將同時啟動兩個進程並使用所需的顏色。
根據您的問題和隨后的評論,這是我對您的批處理文件內容的最佳猜測:
@Start "Shell 1" /D "%UserProfile%\myPython" "%SystemRoot%\System32\cmd.exe" /D /K "py.exe myFile.py"
@Start "Shell 2" /D "%UserProfile%\myPython" "%SystemRoot%\System32\cmd.exe" /D /T:E5 /K "py.exe myFile.py"
我假設您應該能夠根據start
和cmd
命令(即start /?
和cmd /?
)的使用信息自行調整標題、文件路徑和顏色組合。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.