这是bat文件的内容,如果在w10上的命令提示符窗口中调用它,它就可以正常工作。
C:\temp\curl\curl-7.52.1-win32-mingw\curl-7.52.1-win32-mingw\bin\curl.exe "https://www.google.it/search?q=some+word+to+search" -H "accept-encoding: gzip, deflate, sdch, br" -H "accept-language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4" -H "upgrade-insecure-requests: 1" -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" -H "x-chrome-uma-enabled: 1" -H "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "cache-control: max-age=0" -H "avail-dictionary: fmyVnlmA" -H "authority: www.google.it" -H "cookie: SID=CwTQtVs4fYt7DB3Dab_RV-CCb1MW_MoS4VqI1Quc5QInjio_9oaCtPX7Urm1H8plNmxthw.; HSID=AEuEIAvmo0gkQb0oT; SSID=AwN8NmVpx07HoQN9U; APISID=Lq3KiU9ffF2sSMDj/A89BR9KDMqlIjifZn; SAPISID=Fuv16j3VfLymbSNt/AgtVQZanYauCV_gEA; CONSENT=YES+IT.it+V8; OGPC=787587072-4:732465152-1:; NID=95=EgcASSzyHBsH2WmudwsVB3jvXegE3lhHs8Y6cF75ypHCL1pXTL_ZJET5yGIZEY6W64Lhh9k66dCkU5-dVKp3g4AOYSTYvg02bV9v_Xj0W9T7MyJEqFhqt9L3Y_S5wor6ClwWbfcC05SipOYulgpS4MoYYoO3zBc5CINq_cy6bpCHS-3ti1Um87bPQwjLZKQJTOm2PMpvzfLBWGbKnC4WjUo9kzjRYv7vUdyUN_2FiA; DV=oh8FotuvYScXBMhGFNhXdO3l9-t4swI" -H "x-client-data: CIW2yQEIo7bJAQjEtskBCKuKygEI+5zKAQipncoB" --compressed --proxy http://proxyserver:8080
从DotNet调用它没有启动,这是代码:
using (Process p = new Process())
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName= @"C:\temp\curl\call.bat";
p.Start();
p.WaitForExit();
using (StreamReader reader = p.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
}
}