Closing DOS Window

After executing a DOS batch file from within my VB5 application using Shell("BatchFile.bat"), the DOS window remain open, how do I close it from within my application ? I have put EXIT at the end of the Batch file but it will not close the DOS window.  Can anyone help ??
tinsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mraghuvCommented:
I too do a similar activity.
Can you show the code to the batch file.
0
BeedleGuisCommented:
you could close it with api calls:

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const WM_CLOSE = &H10


 Dim winhndl As Long
    Dim RetVal As Long
    winhndl = FindWindow(vbNullString, "Finished - Test")
    If winhndl > 0 Then
       RetVal = PostMessage(winhndl, WM_CLOSE, 0, 0)
    End If

where finished - test is the title of your dos window
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mark2150Commented:
Set the properties on COMMAND.COM to CLOSE ON EXIT.

M

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

tinsonAuthor Commented:
The Batch file BatchFile.bat contains

   type test.txt > lpt1

where test.txt contains one line which is an ESC Sequence to control a printer and it is simply

   ]d0

where the "]" character is chr(27) which is an Escape character.

I am doing this because I am having difficulties sending ESC characters to the printer directly from VB5.
0
tinsonAuthor Commented:
I have tried setting the properties on COMMAND.COM to CLOSE ON EXIT and it does not seem to close the DOS window when finished.
0
BeedleGuisCommented:
that did'nt work on mine mark2150 . .by the way tinson your findwindow line from my proposed answer would be:
winhndl = FindWindow(vbNullString, "Finished - BatchFile")
and depending on how long it takes the batch file to execute you might want to loop the findwindow as follows

winhndl = FindWindow(vbNullString, "Finished - BatchFile")
while winhndle = 0
    winhndl = FindWindow(vbNullString, "Finished - BatchFile")
wend
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.