C# 用process运行一个程序,并得到返回值,为什么无法隐藏那个黑色的cmd窗体

C#用process运行一个程序rasdial.exe,并得到返回值,每次运行时,都会闪出一个cmd运行窗体,p.StartInfo.WindowStyle=system... C# 用process运行一个程序rasdial.exe,并得到返回值,每次运行时,都会闪出一个cmd运行窗体, p.StartInfo.WindowStyle = system.Diagnostics.ProcessWindowStyle.Minimized;也还是不能隐藏,怎么回事
public string DisALlConnect()
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "rasdial";
p.StartInfo.Arguments = "/disconnect";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
p.Start();
p.WaitForExit();
return p.StandardOutput.ReadToEnd();
}
展开
 我来答
百度网友94f02eb
推荐于2016-04-16 · TA获得超过8612个赞
知道大有可为答主
回答量:7955
采纳率:74%
帮助的人:4369万
展开全部
public string DisALlConnect()
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "rasdial";
p.StartInfo.Arguments = "/disconnect";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.Start();
p.WaitForExit();
return p.StandardOutput.ReadToEnd();
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
最后的仙人
2009-08-02 · TA获得超过1961个赞
知道大有可为答主
回答量:1509
采纳率:0%
帮助的人:1375万
展开全部
p.Start();
p.WaitForExit(1000);
p.Close();
return p.StandardOutput.ReadToEnd();
加个p.Close();试试,我的是直接就消失的
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式