| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3580 人关注过本帖
标题:C#中如何调用系统命令
取消只看楼主 加入收藏
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
 问题点数:0 回复次数:6 
C#中如何调用系统命令
是用using System.Threading ?怎么用?求助
搜索更多相关主题的帖子: 命令 系统 Threading using System 
2007-06-30 09:00
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 

我查了一个程序,但什么也没有。已经发上来了,帮忙看一哈


真的想象风一样去流浪!
2007-06-30 11:19
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 

using System;
using System.Diagnostics;

namespace cmd
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Process p=new Process();
p.StartInfo .FileName ="cmd.exe";

p.StartInfo .UseShellExecute =false;
p.StartInfo .RedirectStandardInput =true;
p.StartInfo .RedirectStandardOutput =true;
p.StartInfo.RedirectStandardError =true;
p.Start ();
p.StandardInput.WriteLine("ping -n 1 192.168.1.40");

p.StandardInput.WriteLine("exit");
string strRst = p.StandardOutput.ReadToEnd();

}
}
}
我尝试一下,但只弹出一个窗口后什么也没有了,而我有Ping查看又能看到结果,请高手指教!


真的想象风一样去流浪!
2007-06-30 15:38
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 

什么都没有的嘛?我昏哦?


真的想象风一样去流浪!
2007-07-02 15:42
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 
回复:(jockey)发上来在哪?

using System;
using System.Diagnostics;

namespace cmd
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Process p=new Process();
p.StartInfo .FileName ="cmd.exe";

p.StartInfo .UseShellExecute =false;
p.StartInfo .RedirectStandardInput =true;
p.StartInfo .RedirectStandardOutput =true;
p.StartInfo.RedirectStandardError =true;
p.Start ();
p.StandardInput.WriteLine("ping -n 1 192.168.1.40");

p.StandardInput.WriteLine("exit");
string strRst = p.StandardOutput.ReadToEnd();

}
}
}
我尝试一下,但只弹出一个窗口后什么也没有了,而我有Ping查看又能看到结果,请高手指教!


真的想象风一样去流浪!
2007-07-03 08:42
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 

谢谢大牛哈!看到结果了


真的想象风一样去流浪!
2007-07-03 16:15
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 
可不可以给小弟解释一下原因?

真的想象风一样去流浪!
2007-07-03 16:17
快速回复:C#中如何调用系统命令
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016366 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved