[英]How to use process.StartInfo.Arguments in command prompt?
I wanted to use my c# visual studio to open command prompt using process.StartInfo.FileName and process.StartInfo.Arguments to give commands automatically however this does not work out. 我想使用c#visual studio使用process.StartInfo.FileName和process.StartInfo.Arguments打开命令提示符以自动提供命令,但是这无法解决。 Anyone knows how to do this? 有人知道该怎么做吗? ( I am using the cmd to call for my python script ) (我正在使用cmd来调用我的python脚本)
Try using the following. 尝试使用以下内容。 Hope this helps. 希望这可以帮助。 Replace notepad.exe with something else you like. 用其他您喜欢的东西替换notepad.exe。
Process p = new Process();
p.StartInfo = new ProcessStartInfo("cmd.exe", "/c notepad.exe");
p.Start();
Please refer to http://ss64.com/nt/cmd.html for more details. 有关更多详细信息,请访问http://ss64.com/nt/cmd.html 。
This opens notepad and a file called foo 这将打开记事本和一个名为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
So for your thing you would call the python interpreter and pass the python script as arguments, along with anything else the interpreter needs (I have 0.1% knowledge of python) 因此,对于您而言,您将调用python解释器并将python脚本作为参数以及解释器需要的其他任何参数传递(我对python的了解为0.1%)
Important note: Make sure your executable is in the path. 重要说明:确保可执行文件在路径中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.