C#将多个参数传递给BAT文件
-
12-11-2019 - |
题
我有这个蝙蝠文件“iarp.bat”
Content Begin
@ECHO OFF
npg -vv -f %1 -d %2
Content End
.
,我正在尝试将文件名(循环中)作为第一个参数和设备名称(以前声明的变量)作为第二个参数。我正在尝试这样做:
for (int i = 1; i < arpFiles.Count; i++) {
p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.WorkingDirectory = Application.StartupPath;
p.StartInfo.FileName = Application.StartupPath + "\\iARP.bat";
String argument1 = Application.StartupPath + "\\" + arpFiles[0].Name;
p.StartInfo.Arguments = argument1 + deviceName;
p.StartInfo.Verb = "runas";
p.StartInfo.CreateNoWindow = true;
p.Start();
}
.
btw arpfiles= list 但它没有执行任何人都可以帮助我吗?
解决方案
您需要在Arguments
属性中指定它们:
p.StartInfo.Arguments = string.Format("{0} {1}", argument1, argument2);
. 不隶属于 StackOverflow