S
S
sputnickk2018-12-07 17:02:11
Command line
sputnickk, 2018-12-07 17:02:11

How to pass data from cmd.exe window?

From the program (Frame 3.5 winforms) I call the batch file and read the result of the execution, as well as the error, if it happens.

var processInfo = new ProcessStartInfo("cmd.exe", "/c " + "c:/app/remote.bat");

 processInfo.RedirectStandardError = true;
 processInfo.RedirectStandardOutput = true;
 var process = Process.Start(processInfo);
 
 string             error = process.StandardError.ReadToEnd();

error I send the variable to the remote machine:
File.AppendAllText("\\remoteserver\\app\error.txt" ,  "ОШИБКA: " + error + Environment.NewLine, Encoding.UTF8);

On Win 10 - everything is beautiful, the error is readable (Cyrillic), I run it on WinXP:
ERROR: "uppdate
"

In the batch file, the encoding is UTF, in error.txt - too. Where else to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-12-07
@Stalker_RED

You have utf8 in the sources, and in WinXP cp1251, for example, and in some places even cp866.
You need to specify the correct encoding.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question