Link to home
Start Free TrialLog in
Avatar of smithmrk
smithmrkFlag for United States of America

asked on

Call a Batch File and Wait Til Complete

Hello Experts!

I need to write a program that will loop through a series of date directories and pass in the folder name to a batch file, let the batch file run and then loop to the next directory.

For Example:
        For Each ProcessDate In clb_ProcessDates.CheckedItems
            Call Shell("Run.bat" & " " & ProcessDate.ToString)
        Next

The probblem is I need to wait til the Run.bat (Batch File) has completed until I move on to the next process date.

How can I determine when the batch file has completed and move to the next date?

Thanks,
Mark
Avatar of wdosanjos
wdosanjos
Flag of United States of America image

Please try the following:

        For Each ProcessDate In clb_ProcessDates.CheckedItems
            Dim p As Process = Process.Start("Run.bat" & " " & ProcessDate.ToString)
            p.WaitForExit()
        Next

Open in new window


More on the Process class here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

Avatar of smithmrk

ASKER

I tried that already, and I get file not found.  The problem is my paramater (ProcessDate.String), the Process.Start doesn't like it, because if I take out the paramater and just run (Run.bat) it works fine.

I need the ablity to pass in that paramater into the batch file.

Mark
ASKER CERTIFIED SOLUTION
Avatar of wdosanjos
wdosanjos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!!!!!

Thanks,
Mark