C # Passer plusieurs arguments au fichier BAT
-
12-11-2019 - |
Question
J'ai ce fichier de chauve-souris "iarp.bat"
Content Begin
@ECHO OFF
npg -vv -f %1 -d %2
Content End
Et j'essaie de passer un nom de fichier (dans une boucle) comme premier argument et nom de périphérique (variable précédemment déclarée) comme deuxième argument. J'essaye de faire ceci:
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 mais il ne s'exécute pas peut-on m'aider à ce sujet?
La solution
Vous devez les spécifier tous dans le Arguments
propriété:
p.StartInfo.Arguments = string.Format("{0} {1}", argument1, argument2);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow