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

调用什么系统命令?

2007-06-30 09:21
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 

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


真的想象风一样去流浪!
2007-06-30 11:19
jockey
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:977
专家分:52
注 册:2005-12-4
收藏
得分:0 
发上来在哪?

2007-06-30 15:26
随风云
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
snipen
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2007-5-5
收藏
得分:0 
回复:(随风云)using System;using System.Diagnost...
System.Diagnostics .Process .Start("C:");
打开C盘。
其他的也和这个差不多的意思。。。。。

[此贴子已经被作者于2007-6-30 19:50:12编辑过]


像我这么拉风的男孩子,就像是黑暗中的萤火虫那样,在哪里都是那么的鲜明出众……
2007-06-30 19:47
随风云
Rank: 1
等 级:新手上路
威 望:1
帖 子:263
专家分:0
注 册:2007-6-28
收藏
得分:0 

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


真的想象风一样去流浪!
2007-07-02 15:42
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
用Process 的时候,可别忘了关闭哦.

飘过~~
2007-07-02 16:18
随风云
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
jockey
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:977
专家分:52
注 册:2005-12-4
收藏
得分:0 
加一句话:

MessageBox.Show(strRst);

2007-07-03 13:22
快速回复:C#中如何调用系统命令
数据加载中...
 
   



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

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