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

Close DOS Shell after executing 1

Status
Not open for further replies.

Pistol34

MIS
Nov 17, 1999
55
US
I execute a DOS exe using the shell function and the win 98 DOS shell pops up and the shell stays open. I am tring to execute a number of files back to back. How can I close the window so that I don't have 30 windows open? Is there any other info I can retrieve from Windows about other running apps?

Thanks,

Pete
 
If you open a DOS Prompt and lick on the font button then the program tab you will see a checkbox labeled "Close on exit", Make sure it is checked.
Unfortunately this needs to be done manually on the users machine(s). I do not know of a way to do it programatically.
 

BruceHesher, you took the words out of my mouth. QUOTE OF THE DAY
The most important ingredient in the formula of success is knowing how to get along with people.

Jr_Clown :eek:)
 
On Error GoTo NotOpen


'Maybe a loop
AppActivate "MS-Dos Prompt", 1
'DO STuff
'end maybe a loop
'(I am assuming you already are aware of SendKeys not working directly )

NotOpen:
If Err.Number = 5
Shell ("Command.com")
Resume
end if
End sub
 
I assume here that the shelled application finishes but leaves an open window waiting for you to manually close it. Here's a way to do it without *licking* any buttons (sorry Bruce):

First read faq222-32. It shows a way to determine whether a shelled process has ended.

Then use these API functions:[tt]
Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal _
lpString As String, ByVal cch As Long) As Long
Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
[/tt]

You could use [tt]GetWindowText[/tt] to see if there is window containing the text "finished" and then call [tt] SendMessage app_hwnd, &H10, 0, 0 [/tt] to close the window.

VCA.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top