using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Media;
using System.Diagnostics;
using System.IO;
private void Form1_Load(object sender, EventArgs e)
{
string MyDosComLine1 = "ping www.baidu.com >nul";
string MyDosComLine2= "if %errorlevel% == 0 echo 成功";
string MyDosComLine3 = "if %errorlevel% == 1 echo 远程计算机连接失败,原因可能为远程计算机未开启或网络超时!";
Process myProcess = new Process();
myProcess.StartInfo.FileName = "cmd.exe ";//打开DOS控制平台
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;//是否显示DOS窗口,true代表隐藏;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;//标准输入流
sIn.AutoFlush = true;
StreamReader sOut = myProcess.StandardOutput;//标准输入流
StreamReader sErr = myProcess.StandardError;//标准错误流
sIn.Write(MyDosComLine1,System.Environment.NewLine);//第一条DOS命令
sIn.Write(MyDosComLine2, System.Environment.NewLine);
sIn.Write(MyDosComLine3, System.Environment.NewLine);
//sIn.Write("exit",System.Environment.NewLine);//第四条DOS命令,退出DOS窗口string s = sOut.ReadToEnd();//读取执行DOS命令后输出信息
string er = sErr.ReadToEnd();//读取执行DOS命令后错误信息
MessageBox.Show(er);
MessageBox.Show(s);
}为什么弹框没有值啊
求助啊
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Media;
using System.Diagnostics;
using System.IO;
private void Form1_Load(object sender, EventArgs e)
{
string MyDosComLine1 = "ping www.baidu.com >nul";
string MyDosComLine2= "if %errorlevel% == 0 echo 成功";
string MyDosComLine3 = "if %errorlevel% == 1 echo 远程计算机连接失败,原因可能为远程计算机未开启或网络超时!";
Process myProcess = new Process();
myProcess.StartInfo.FileName = "cmd.exe ";//打开DOS控制平台
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = false;//是否显示DOS窗口,true代表隐藏;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.Start();
StreamWriter sIn = myProcess.StandardInput;//标准输入流
sIn.AutoFlush = true;
StreamReader sOut = myProcess.StandardOutput;//标准输入流
StreamReader sErr = myProcess.StandardError;//标准错误流
sIn.Write(MyDosComLine1,System.Environment.NewLine);//第一条DOS命令
sIn.Write(MyDosComLine2, System.Environment.NewLine);
sIn.Write(MyDosComLine3, System.Environment.NewLine);
//sIn.Write("exit",System.Environment.NewLine);//第四条DOS命令,退出DOS窗口string s = sOut.ReadToEnd();//读取执行DOS命令后输出信息
string er = sErr.ReadToEnd();//读取执行DOS命令后错误信息
MessageBox.Show(er);
MessageBox.Show(s);
}为什么弹框没有值啊
求助啊
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货