
Using CreateProcess or ShellExecute (VB4-32Bit)
Can someone suggest a method to get a batch file to
close after it has been invoked in Windows 95 by either
ShellExecute or CreateProcess ?
See code sample below:
Private Sub ProcessDiskFile()
Timer1.Enabled = False
'tried to run ShellExecute which works fine also
'just that it in the same way as ExecCmd, does not
'close the DOS Finished - A Box
' Dim Scr_hDC As Long
' Dim StartDoc As Long
' Scr_hDC = GetDesktopWindow()
' StartDoc = ShellExecute(Scr_hDC, "Open", "A:\A.BAT", "", "A:\",
SW_SHOWNORMAL)
Call ExecCmd("A:\A.BAT")
End Sub
Public Sub ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret&
'Initialize the STARTUPINFO structure
start.cb = Len(start)
'Start the shelled application
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&,
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
'Wait for the shelled application to finish
' -- this line never gets executed -- as the DOS BOX sits
'with a Finished - A message in the caption, as soon as it's
'manually closed, this code is executed.
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
MsgBox "Shelled process has ended"
Timer1.Enabled = True
End Sub
Regards,
R Rasanen
_________________ __ ------------------------
|| \----.________.----/
|| / / `--'
__||____/ /_
|___ \ http://www.*-*-*.com/
`--------' -------------------------
- Its never too late to learn to play the piano -