| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
vb send dos commands to text window
|
Original Message
|
Name: nuguy
Date: May 24, 2006 at 17:23:51 Pacific
Subject: vb send dos commands to text windowOS: windowsCPU/Ram: anyModel/Manufacturer: 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
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Chi Happens
Date: May 25, 2006 at 11:05:11 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: nuguy
Date: June 2, 2006 at 05:56:17 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Chi Happens
Date: June 21, 2006 at 13:48:42 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|

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