无法在单个参数中接收完整参数。
代码
string startupPath = System.IO.Directory.GetCurrentDirectory();
string bat = startupPath + @"\util.bat";
var psi = new ProcessStartInfo();
psi.FileName = @bat;
psi.Verb = "runas";
psi.Arguments = "C:/Program Files (x86)/Windows Kits/8.1/bin/x64" +"param2";
psi.UseShellExecute = true;
Process.Start(psi);
批处理文件:
@ECHO OFF
ECHO.
echo %~1 //this prints "C:/Program Files"
echo %1% //this prints "C:/Program Files"
echo %* //this prints C:/Program Files (x86)/Windows Kits/8.1/bin/x64 param2
cd %1%
echo "done"
ECHO.
PAUSE
CLS
EXIT
我希望在2个不同的变量中收到两个参数,例如%1%和%2%。 我可以在批处理文件上发送和获取它时用逗号分隔它们。但是,想要做到这一点!