Question

I have this BAT file "iARP.BAT"

Content Begin
@ECHO OFF
npg -vv -f %1 -d %2
Content End

And I'm trying to pass a file name (in a loop) as the first argument and device name (variable previously declared) as the second argument. I'm trying to do this:

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 but it is not executing can anyone help me with this?

Was it helpful?

Solution

You need to specify them all in the Arguments property:

p.StartInfo.Arguments = string.Format("{0} {1}", argument1, argument2);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top