Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS from within VB6

Status
Not open for further replies.

jamesknicholson

Programmer
May 3, 2003
4
GB
How can I run the ipconfig command in dos and get the values into my VB textboxes?
 
You could use the shell command. You could > the ipconfig stuff to a file ipconfig > text.txt and then you could read the contents of text.txt and put the stuff into your textboxes. You could search google for pushkeys as that is a utility that allows you to send and receive data between applications
 
You cannot use I/O redirection (with > and < etc) with Shell statement. These features only work within DOS environment. It means that [tt]Shell &quot;ipconfig.exe > ip.txt&quot;[/tt] will not work.

You also asked this question in thread222-535407. Go there for an alternate solution.
 
Hypetia,
Shell &quot;ipconfig >c:\listAA.txt&quot;
don't work, as you said.

But
Shell &quot;command.com /c ipconfig >c:\listAA.txt&quot;
works under 98.
 
If my memory serves me correctly, Tek-Tips user strongm addressed this problem a few months ago. Unfortunately, I can't find the thread.

...something about collecting the application output after running it in a console... Sorry... getting old and feeble....


vcn.gif

Suffice it to say that adding disk drives and a disk operating system to a personal microcomputer is guaranteed to increase its power dramatically.
CP/M and the Personal Computer
 
I think that the particular solution of mine that you are thinking about Alt255 maybe a little bit of overkill, as it was a technique for allowing a VB application to work like a console application.

However for those interested, here's the original thread including a code walkthrough: thread222-255803

There was also a complementary thread which showed how to start up any VB6 application as a console application (which meant it could then interact with the commandline it was launched from). However, I don't seem to be able to find that thread at the moment.
 
tsh73, thanks for the info. I'll try that.

Alt255, a quick keyword search on AllocConsole gave me seven threads closely related to console programming.
Three of them, belonging to this very forum, are listed below.

Console applications. thread222-3303
Output to StdOut. thread222-295057
Shelling to Command Prompt to run a DOS command? thread222-6502
 
Yep, there are lots of basic AllocConsole solutions posted. For all the functionality they provide, most can be more-or-less replaced with:

Private Sub Form_Load()
Text1.Move 0, 0, Form1.Width, Form1.Height
Text1.BackColor = vbBlack
Text1.ForeColor = vbWhite
End Sub
 
I had to do this exact thing recently and I just called a batch file with the shell command, and the batch file had the output redirection in it. A bit hokey for a true commercial setting, but not a bad solution if you are only using a program internally.
 
I've found the complementary thread that I mentioned above: Thread222-339817
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top