DOS命令输出重定向 [英] DOS Command output redirection

查看:92
本文介绍了DOS命令输出重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想从vb.net运行DOS命令,例如"net session",并将输出重定向到字符串变量.有人可以给我示例代码来做到这一点吗? plz

谢谢
Suhail

Hi,

I want to run DOS commands like "net sessions" from vb.net and redirect the output to string variable. Can somebody give me the sample code to do this? plz

Thank you
Suhail

推荐答案

这里是一种方法(在C#中,但很容易转换为VB):

Here''s one way (in C#, but easily translatable to VB):

Process proc = new Process 
{
    StartInfo = new ProcessStartInfo 
    {
        FileName = "program.exe",
        Arguments = "command line arguments to your executable",
        UseShellExecute = false,
        RedirectStandardOutput = true,
        CreateNoWindow = true
    }
};
proc.Start();
while (!proc.StandardOutput.EndofStream) 
{
    string line = proc.StandardOutput.ReadLine();
    // do something with output
}


如果那还不够的话,当我搜索"c#过程对象获取输出"时,google提供了超过6百万条结果.


If that''s not adequate, google provided over 6 MILLION results when I searched for "c# process object get output".


每个人都可以停止询问"DOS命令"吗?不再有这样的事情了.谢天谢地!
您感兴趣的程序是"get.exe",常规的Windows保护模式应用程序,PE文件( http://en .wikipedia.org/wiki/Portable_Executable [ ^ ] ).
不,这不只是术语.这是对基本事物的理解不足.

—SA
Can everyone stop asking about "DOS command"? There is no such thing anymore. Thanks goodness!
The program you''re interested in is "get.exe", regular Windows protected-mode application, PE file (http://en.wikipedia.org/wiki/Portable_Executable[^]).
No, this is not just terminology. This is lack of understanding of basic things.

—SA


这篇关于DOS命令输出重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆