[英]How to pass multiple argments with process.startInfo.Arguments
[英]How to use process.StartInfo.Arguments in command prompt?
我想使用c#visual studio使用process.StartInfo.FileName和process.StartInfo.Arguments打開命令提示符以自動提供命令,但是這無法解決。 有人知道該怎么做嗎? (我正在使用cmd來調用我的python腳本)
嘗試使用以下內容。 希望這可以幫助。 用其他您喜歡的東西替換notepad.exe。
Process p = new Process();
p.StartInfo = new ProcessStartInfo("cmd.exe", "/c notepad.exe");
p.Start();
有關更多詳細信息,請訪問http://ss64.com/nt/cmd.html 。
這將打開記事本和一個名為foo的文件
var procInfo = new ProcessStartInfo("notepad");
procInfo.Arguments = "foo.txt";
var proc = new Process();
proc.StartInfo = procInfo;
proc.Start(); //Actually executes the process
proc.WaitForExit(); //Waits until the process completes, in this case, when you close notepad
因此,對於您而言,您將調用python解釋器並將python腳本作為參數以及解釋器需要的其他任何參數傳遞(我對python的了解為0.1%)
重要說明:確保可執行文件在路徑中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.