【问题标题】:bat file sequential issue, start a script after the first one finish [duplicate]bat文件顺序问题,在第一个完成后启动脚本[重复]
【发布时间】:2018-05-02 17:56:51
【问题描述】:

我创建了一个.bat 文件,它将运行四个脚本,我想做的是在前三个脚本完成后,然后启动最后一个脚本,我该怎么做?

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

【问题讨论】:

    标签: batch-file


    【解决方案1】:

    您可以为START 甚至/B 使用/WAIT 开关来停止每次创建新的cmd.exe 窗口:

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

    更多选项请运行START /?。 :)

    如果您不想等待每个 MSSQL 程序,那么除非您想检查具有此名称的进程是否在某个地方仍然存在(可能与某个进程发生冲突),否则没有这样的事情可以帮助您你还没有运行)-this answer 解释了如何运行。

    一个小例子:

    @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
    )
    

    运行此示例,观察如果关闭所有 NOTEPAD.EXE 窗口会发生什么。

    【讨论】:

      猜你喜欢
      • 2010-11-03
      • 1970-01-01
      • 2020-07-27
      • 2011-11-21
      • 2014-05-06
      • 2014-10-01
      • 2013-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多