1

I create a .bat file, Which will run four scripts, what I want to do is after the first three scripts finished, then start the last script, how should I do that?

start MSSQL2PostgreSQLPro_Cons.exe /Session:"Yardi-brian"
timeout /t 120
start MSSQL2PostgreSQLPro_Cons.exe /Session:"Yardi-lake"
timeout /t 120
start MSSQL2PostgreSQLPro_Cons.exe /Session:"Yardi quan"

C:\Python27\python.exe C:\yardi_backup\detect.py
Yang L
  • 331
  • 1
  • 9

1 Answers1

0

You can use the /WAIT switch for START and even /B to stop creating new cmd.exe window each time:

start /B /wait timeout /t 1
start /B /wait timeout /t 1
start /B /wait timeout /t 1

For more options run START /?. :)

In case you don't want to wait for each of the MSSQL programs, then there's no such thing that might help you unless you want to check whether a process with this name is still alive somewhere (which might collide with a process you haven't run) - this answer explains how to.

A little example:

@echo off
start notepad
start notepad
start notepad

:check
tasklist /FI "IMAGENAME eq notepad.exe" 2>NUL | find /I /N "notepad.exe">NUL
if "%ERRORLEVEL%"=="1" (
    echo Program is not running
) else (
    goto check
)

Run this example watch what happens if you close all NOTEPAD.EXE windows.

Peter Badida
  • 7,432
  • 8
  • 33
  • 74