|
How to make your app wait for batch execution
Have you ever wanted to put your application on hold while a batch file or a DOS program runs? Here is how you can do it:
Author: Øystein Selbekk
'This example lets you start any program or batch file through the MS-DOS prompt.
'The example requires that msvcrt.dll is installed on the system.
'It also requires that you have a batch file named c:\mybatch.bat that does some processing.
'Here is how you do it:
'1. create a new project. Choose a standard EXE project.
'2. The project will automatically create a new form.
'3. Add a button to the form. It will automatically be called command1.
'4. Change the caption value of command1 to: Launch batch file.
'5. Add a .bas module.
'6. Add this code to the new .bas module:
Option Explicit
Public Declare Function system Lib "msvcrt.dll" (ByVal sCommand As String) As Long
'7. Add this code to the command1_click() function
'(You can open the function by doubleclicking on the command1 button)
Private Sub Command1_Click()
Dim lTmp As Long
On Error Resume Next
lTmp = system("c:\mybatch.bat")
On Error GoTo 0
MsgBox "The batch file has terminated! You can now continue the rest of your processing"
End Sub
|
||
|
Editor: Øystein Selbekk Last update: 2025-10-29 Copyright 1995-2025 VBI |