Computing.Net > Forums > Programming > vb send dos commands to text window

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

vb send dos commands to text window

Reply to Message Icon

Name: nuguy
Date: May 24, 2006 at 17:23:51 Pacific
OS: windows
CPU/Ram: any
Product: any
Comment:

hello all - I'm using vb8 - I'm having difficulty trying to figure out how to send a dos command to the console and output to a textwindow. I want to do this without having a console window open in the process - An example would be a simple form with one button and one text window - lets say the button was for "ipconfig" - when pressed it would simply display the "exact" output of the command prompt in the textwindow - also i want this to be down without the program referencing any external resources; such as batchfiles or writng to a textfile then reading from it - I've looked around on the web and havent found much that directly suits my need - I'm sure it can be done but with all of my noobishness I need some direction by the higher ups - this is a great site and i have found much help from it in the past and many thanks in advance to all who participate - if some would like to propose a resolution in c# - feel free



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: May 25, 2006 at 11:05:11 Pacific
Reply:

Here is one way

Dim p = New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.FileName = "ipconfig"
p.Start()
p.WaitForExit()
Dim output As String
output = p.StandardOutput.ReadToEnd()

Console.Write(output)


in c#:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "ipconfig";
p.Start();
p.WaitForExit();
string output = p.StandardOutput.ReadToEnd();


They mostly come at night...mostly.


0

Response Number 2
Name: nuguy
Date: June 2, 2006 at 05:56:17 Pacific
Reply:

very nice - chi - a couple of questions though -

would I add this to the button click event?
and if i wanted to pass arguments to the ipconfig command such as "ipconfig /all" - would i include "process.StartInfo.Arguments = Arguments;"? - i found something similar here - http://www.codeproject.com/csharp/LaunchProcess.asp - from what i gather - i may not be able to add a second button performing a similar task due to multithreading issues? -

Thanks again for your help


0

Response Number 3
Name: Chi Happens
Date: June 21, 2006 at 13:48:42 Pacific
Reply:

You can use the arguments property to set arguments and as far as multithreading...I don't know, I guess it all depends on what you are trying to launch. If you are using an XP system, then I think you should be able to multithread with no prob.

Chi

They mostly come at night...mostly.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


find large files recursiv... Delphi 5 Question



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: vb send dos commands to text window

how to manipulated windows command www.computing.net/answers/programming/how-to-manipulated-windows-command/14736.html

VB Changing from Masked to text ctrl www.computing.net/answers/programming/vb-changing-from-masked-to-text-ctrl/2995.html

convert dos program to windows www.computing.net/answers/programming/convert-dos-program-to-windows/10472.html