【发布时间】:2015-06-17 10:43:55
【问题描述】:
我有一个运行.bat 和.vbs 文件的控制台应用程序。
启动这些进程的方法如下:
public void runProcess(string aPath,string aName,string aFiletype)
{
string stInfoFileName;
string stInfoArgs;
if(aFiletype == "bat")
{
stInfoFileName = (@aPath + @aName);
stInfoArgs = string.Empty;
}
else
{ //vbs
stInfoFileName = @"cscript";
stInfoArgs = "//B //Nologo " + aName;
}
this.aProcess.StartInfo.FileName = stInfoFileName;
this.aProcess.StartInfo.Arguments = stInfoArgs;
this.aProcess.StartInfo.WorkingDirectory = @aPath;
this.aProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
this.aProcess.Start();
Console.WriteLine("information passed from batch: ???");
this.aProcess.WaitForExit(); //<-- Optional if you want program running until your script exit
this.aProcess.Close();
}
它正在启动的当前.bat 文件用于通过ftp(ftp、ftps 或sftp)发送数据。
当进程运行时,所有信息都会显示在进程窗口中,例如可能会发生错误,文件未传输,并且此“子”进程窗口中会显示一条详细说明此问题的消息。进程完成后,“子”窗口会与消息一起消失。
我能否以某种方式将这些有用信息返回到我的主控制台应用程序窗口?
【问题讨论】:
标签: c# windows batch-file ftp ftps