下面一段代码中,
如果strDos赋值为ipconfig,程序能运行
如果strDos赋值为exp system/huahua@myoracle full=y file=d:\\mm.dmp ,程序不能成功执行但是直接在dos窗口中运行exp system/huahua@myoracle full=y file=d:\\mm.dmp 能成功执行这是为什么?程序应该怎么改?谢谢
private void button1_Click(object sender, EventArgs e)
{ string strDos = ""; //strDos = "ipconfig"; //(1)
strDos = "exp system/huahua@myoracle full=y file=d:\\mm.dmp";//(2)
//实例一个Process类,启动一个独立进程
Process p = new Process();
p.StartInfo.FileName = "cmd.exe"; //设定程序名
p.StartInfo.Arguments = "/c " + strDos; //设定程式执行参数 /c 关闭窗口 /k不关闭窗口
p.StartInfo.UseShellExecute = false; //关闭Shell的使用
p.StartInfo.RedirectStandardInput = true; //重定向标准输入
p.StartInfo.RedirectStandardOutput = true; //重定向标准输出
p.StartInfo.RedirectStandardError = true; //重定向错误输出
p.StartInfo.CreateNoWindow = true; //设置不显示窗口 p.Start(); //启动 MessageBox.Show(p.StandardOutput.ReadToEnd().ToString()); }
如果strDos赋值为ipconfig,程序能运行
如果strDos赋值为exp system/huahua@myoracle full=y file=d:\\mm.dmp ,程序不能成功执行但是直接在dos窗口中运行exp system/huahua@myoracle full=y file=d:\\mm.dmp 能成功执行这是为什么?程序应该怎么改?谢谢
private void button1_Click(object sender, EventArgs e)
{ string strDos = ""; //strDos = "ipconfig"; //(1)
strDos = "exp system/huahua@myoracle full=y file=d:\\mm.dmp";//(2)
//实例一个Process类,启动一个独立进程
Process p = new Process();
p.StartInfo.FileName = "cmd.exe"; //设定程序名
p.StartInfo.Arguments = "/c " + strDos; //设定程式执行参数 /c 关闭窗口 /k不关闭窗口
p.StartInfo.UseShellExecute = false; //关闭Shell的使用
p.StartInfo.RedirectStandardInput = true; //重定向标准输入
p.StartInfo.RedirectStandardOutput = true; //重定向标准输出
p.StartInfo.RedirectStandardError = true; //重定向错误输出
p.StartInfo.CreateNoWindow = true; //设置不显示窗口 p.Start(); //启动 MessageBox.Show(p.StandardOutput.ReadToEnd().ToString()); }
非dos下要绝对路径~
去掉空格怎么处理