Using CreateProcess or ShellExecute (VB4-32Bit) 
Author Message
 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 -



Sat, 18 Jul 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. shell a file (as with shellExecute) AND wait for its return (as with CreateProcess)

2. VB5 Question about CreateProcess 32bit API call

3. Out of Stack 28 using VB4-32bit with Office 97 Installed

4. Out of Stack 28 using VB4-32bit with Office 97 Installed

5. executing 32bit dll's in VB4 using 32-bit C

6. IP Address using VB4.0-32bit

7. convert VB3 project to 32bit using VB4?

8. Upgrade Problems: VB4.0/16Bit to VB4.0/32Bit

9. VB4 16bit Vs. VB4 32bit???

10. Programe works without problems when using VB4/32bit but doesn't work when using VB4/16bit

11. Please help with CreateProcess API call (VB4-32)

12. Problem getting this program to start using shell, shellexecute and createprocess?

 

 
Powered by phpBB® Forum Software