-
Is it possible...
Hi, I'm just wondering if it is at all possible to capture the data (text), in the command prompt window, and port it into my program? The way the program runs is that it opens a command window (cmd.exe/Win2K) performs a function and then the second that the results appear, the window terminates and I don't have time to see the results, it just flashes and closes.
So I'm looking for either a foolproof way to keep the window open, or capture the text and put it into a V.B. Listbox.
Thanx in advance for you help,
Scott
-
IS it possible....Yes
Private Sub Command1_Click()
Dim Data As String
'Call the command prompt and pipe the results to a text file.
Shell "command.com /c c:\windows\ping.exe 127.0.0.1 > c:\xping.tmp", vbHide
Delay 3 'Call the subprocedure Delay to allow the command prompt time to create
'the file you are going to open.
Open "c:\xping.tmp" For Input As #1 'Open the file.
Do While Not EOF(1) 'While not at the end of the file read each string
Input #1, Data 'Place it value in Data
Form1.Text1 = Form1.Text1 & vbCrLf & Data 'Append the value of data in the mulitline text box for each loop
Loop
Close #1
End Sub
Public Sub Delay(HowLong As Date)
TempTime = DateAdd("s", HowLong, Now)
While TempTime > Now
DoEvents
Wend
End Sub
Private Sub Command2_Click()
Close Form
End
End Sub
-
What exactly are you trying to do? You might not even need to use the command prompt. For example, you can get your ip address or ping someone using the API. If you are running a batch file, you can put "pause" as the last line.