My mistake, it should have been a Do...Loop, not an If..Then
I have 1 main (global) module, that contains Sub Main, then 5 individual import modules that execute my DTS packages to import 5 different text files.
The DoStuff module is in on of my import modules and is called from the main module.
The ExecuteBatchFile procedure is contained in the main module, so the processes.HasExited property can be accessed by the import modules. Because each import module calls a different batch to execute the DTSRun.exe command to run a DTS package.
It basically looks like this (extremely scaled down)
Main Module
VB Code:
Public mobjDTSProcess As Process Public Sub Main() Call DoStuff() End Sub Public Sub ExecuteBatchFile(ByVal strFilePath As String) Try mobjDTSProcess = Process.Start(strFilePath) Catch ex As Exception 'Do something End Try End Sub
Import1 Module
VB Code:
Public mintI As Integer Public Sub DoStuff() ExecuteBatchFile("C:\Test.bat") Do until mobjDTSProcess.HasExited = True OrElse mintI = 4 NotifyUser("Waiting on DTS to complete.") Thread.Sleep(2000) mintI += 1 Loop If mintI = 4 Then 'The DTS process failed Application.Exit() Else 'The DTS process succeeded 'Do more stuff End If End Sub




Reply With Quote