Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何使用C#记录命令提示符上显示的回声图像?_Windows_Command Line_Batch File_C# - Fatal编程技术网

Windows 如何使用C#记录命令提示符上显示的回声图像?

Windows 如何使用C#记录命令提示符上显示的回声图像?,windows,command-line,batch-file,c#,Windows,Command Line,Batch File,C#,我使用下面的函数在C#中调用EAR_Encrypt_FTP.bat。运行批处理文件时,是否有任何方法跟踪cmd.exe中显示的回显消息 我需要处理命令提示符屏幕上显示的回显消息,并记录该过程 private static short batchfileInvoke(string ftpFileName, string headerFile) { short value = 0; Process p = null; try { p = new Pro

我使用下面的函数在C#中调用EAR_Encrypt_FTP.bat。运行批处理文件时,是否有任何方法跟踪cmd.exe中显示的回显消息

我需要处理命令提示符屏幕上显示的回显消息,并记录该过程

private static short batchfileInvoke(string ftpFileName, string headerFile)
{
    short value = 0;
    Process p = null;
    try
    {
        p = new Process();
        ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
        startInfo.FileName = "cmd.exe";
        string argument1 = "EAR_Encrypt_FTP.bat";
        string test = "\"" + ftpFileName + "\"";
        string argument2 = test;
        string test1 = "\"" + headerFile + "\"";
        string argument3 = test1;
        p.StartInfo.WorkingDirectory = Path.GetDirectoryName(argument1);
        startInfo.Arguments = "/C EAREncryptFTP.bat " + argument2 + " " + argument3;
        p.StartInfo = startInfo;
        p.Start();
        p.WaitForExit();
        int value2 = p.ExitCode;
        value = (short)value2;
        if(value==0)
        {
            Console.WriteLine("Encryption process is done");
        }                
    }
    catch (Exception ex)
    {
        Console.WriteLine("Exception Occurred :{0},{1}",
                    ex.Message, ex.StackTrace.ToString());
        value = -4;
    }
    return value;
}  
搜索
c#
控制台
重定向
可能产生。搜索
c#
控制台重定向可能产生。