Building a batch file to run exe files sequentially

前端 未结 4 1675
眼角桃花
眼角桃花 2021-01-12 01:21

I just start to learn how to build batch file. ( on the windows 7 environment)

I want to build the batch file which is able to run .exe files sequentially .

相关标签:
4条回答
  • 2021-01-12 01:33
    start MyDriver.exe
    start YouDriver.exe
    start MySoftware.exe
    

    If you want the batch file in a different dir you would have to do:

    cd D:\
    start MyDriver.exe
    start YouDriver.exe
    start MySoftware.exe
    

    If you want a more flexible system:

    echo Welcome to EXE starter!
    set /p dir = DIR:
    set /p exe = EXE1:
    set /p exe1 = EXE2:
    set /p exe 2 = EXE3:
    cd DIR
    start exe
    start exe1
    start exe2
    

    There you go!

    To do it squentially:

    call YouDriver.exe
    call MeDriver.exe
    call Mysoftware.exe
    

    call will halt the batch file until program has closed.

    0 讨论(0)
  • 2021-01-12 01:40

    Try and put it in the same directory of the files you want to run. If you can't, use cd C:\Directory\Name to change it to the directory where the MyDriver.exe file is. Then just do MyDriver.exe- you don't need a call or start statement.

    MyDriver.exe
    YouDriver.exe
    MySoftware.exe
    

    use cd at the start if you neeed to.

    0 讨论(0)
  • 2021-01-12 01:44

    This will start each file and wait for it to complete and then launch the next one.

    @echo off
    start "" /w /b "d:\MyDriver.exe"
    start "" /w /b "d:\YouDriver.exe"
    start "" /w /b "d:\Mysoftware.exe"
    
    0 讨论(0)
  • 2021-01-12 01:45

    You actually don't need to do anything special to make this happen; batch files are synchronous by default, so execution of the batch file will pause when an executable is launched, and resume when it exits. Something as simple as this should do:

    @echo off
    REM "@echo off" prevents each line from being printed before execution,
    REM and is optional
    REM "REM" introduces a comment line
    D:\MyDriver.exe
    D:\YouDriver.exe
    D:\MySoftware.exe
    

    Of course, if you're interested in checking the return values of the programs, to see whether they succeeded or failed to install (assuming the installer provides that information), then things become slightly more complicated; if that's what you need, mention it in a comment, and I'll expand my answer accordingly.

    0 讨论(0)
提交回复
热议问题