执行在命令提示符下多cammand我想下面执行多个命令:如何使用C#
CD C:\ Informatica的\ 9.0 \用户\ PowerCenterClient \客户端\ BIN
pmrep
连接-r rs_01_lab -d Domain_DELLBANPDB01 -n etl_designer -x etl123
使用C#...
,我已经写如下代码:
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.RedirectStandardInput = true;
info.UseShellExecute = false;
p.StartInfo = info;
p.Start();
using (StreamWriter sw = p.StandardInput)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine("cd C:\Informatica\9.0\clients\PowerCenterClien\client\bin");
sw.WriteLine("pmrep");
sw.WriteLine("connect -r rs_01_lab -d Domain_DELLBANPDB01 -n etl_designer -x etl123");
StreamReader SR = p.StandardOutput;
string myString = SR.ReadToEnd();
sw.WriteLine("mypassword");
sw.WriteLine("use mydb;");
}
}
但我无法在命令提示符下编写命令。
能否请你帮我对此。
由于提前, Sunayana
我与尝试过,它不工作.. – user698105 2011-04-08 07:29:52
如果你不能把它作为一个参数,但它的东西,必须要输入到程序中,你可能会弥补有问题。这可能是因为,similaryly到远程登录,您的“pmrep”应用程序不使用标准输入。这里的一个[用于smiliar问题SO参考](http://stackoverflow.com/questions/2212763/c-telnet-process-w-redirected-standard-streams-quits-immediately) – NKCSS 2011-04-08 07:39:42