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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Messages from DOS-Box to show as MessageBox under VB

Status
Not open for further replies.

ToruX

Programmer
Apr 7, 2001
3
DE
I hope someone can help me,

is there a way to "catch" Messages from a DOS-Box, so that i can show them under VB in a MessageBox (for example) ??

PS: the command for DOS C:\TEST.EXE > TEST.TXT doesn't work for the dos app's i want to use !

I hope someone can help me, this is VERY important.

PPS: sorry for my bad english, i am a foreign language speaker :)

Greets ToruX
 
Hello ToruX,

If you are using aWindows NT or Windows 2000 system there is an easy solution for your problem.
Instead of using C:\TEST.EXE > TEST.TXT try using C:\TEST.EXE | clip (you need to copy a file called clip.exe from the resource pack. this will "pipe" the output to the clipboard.

Then you can use the clipboard.gettext to retrive the data from the clipbord and display it to the mesage box. See the example bellow:


public function getDataFromPrompt()
Clipboard.Clear
Shell "C:\TEST.EXE | clip"
timer1.interval=100
timer1.enabled=true
end Function

Private Sub Timer1_Timer()
Dim DOSWindow as string
Timer1.enable=false
DOSWindow=Clipboard.GetText
msgbox DOSWindow
End Sub

NOTE: The delay of 100ms is needed in order to allow the system to execute the DOS command and return the results to the clipboard (this operation is performed asyncronusly)

On the other hand if you are using another OS or you do not have access to the Resource kit try using the ">>" instead of ">" and then read that file. See the example below


private sub ReadFile()
Dim strLine As String
Dim text As String
Open "d:\test.txt" For Input As #1
While Not EOF(1)
Input #1, strLine
text = text & vbCrLf & strLine
Wend
Close #1
msgbox text
end sub


Again you must allow time for the system to create taht file

I Hope that this helped you
 
Hi Camel,
the dos-command :
test.exe >> test.txt don't work for me because the application uses parameter.

I use Win98SE

Other solutions ?? API ?

Thanks
Greets ToruX
 
ToruX:

Did you try using the reverse directional?

TEST.TXT [red]<[/red] C:\TEST.EXE /param1% /param2% etc.?

Hope this helps some.
--MiggyD &quot;The world shrinks more and more with every new user online.&quot;
 
MiggyD,
Hmmmm . . . I didn't realize that you could reverse the order/direction like that in DOS . . . funny, it never seems to work for me. Would you please let me know how it works for you? Thanks!
- Jeff Marler B-)
 
Hello again,
If you are passing parameters then it is a bit more complicated try something similar to :

private sub test()
Dim param1 As String
Dim param2 As String
param1 = &quot;/w&quot;
param2 = &quot;&quot;
Shell &quot;d:\TEST.bat &quot; & param1 & param2 & &quot; >> d:\text.txt&quot;

end sub


The test.bat is a file that will perform a dir and accept's tow parameters/switchies in the above example i use only the first tahta is the /w

I hope that this will help you overcome your problem

Camel
 
jmarler:

My bad! I wasn't thinking clearly. I was thinking along the lines of:

C:\DOS\DEBUG.EXE [red]<[/red] HexChg.SCR > ChgdHex.com

Sorry! I was technically brain dead (late at night) while typing.....whil type-ing...opps got to gooo.
--MiggyD &quot;The world shrinks more and more with every new user online.&quot;
 
Big thanks @ all,
but i am very frustrated it won't work
command : xdms.exe u pdy-cit1.dms > result.txt
explain:
xdms.exe (the DOS exe to use, compressing tool)
u (the param, to decompress)
pdy-cit1.dms (the compressed file)
> result.txt (the result text, to show if the file correctly decompressed)

BUT result.txt is EMPTY !!!

if i use the DOS Command : xdms.exe > test.txt
then it works perfedctly (it saves the help screen)

ANY OTHER SOLUTIONS TO CATCH DOS MESSAGES ???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top