Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch script stops after first call to other batch script

Tags:

batch-file

I'm attempting to execute a batch script that currently looks like this:

D:
cd D:My Documents\FtpSolution\Test
getftp.bat
call delimconvert.exe
call convert-to-xls.bat

However this stops dead after getftp.bat has run.

What am I doing wrong? It's important that these commands all run sequentially.

like image 699
zib24 Avatar asked Feb 24 '11 16:02

zib24


People also ask

What is @echo off in batch?

When echo is turned off, the command prompt doesn't appear in the Command Prompt window. To display the command prompt again, type echo on. To prevent all commands in a batch file (including the echo off command) from displaying on the screen, on the first line of the batch file type: Copy. @echo off.

What does %1 mean in a batch file?

When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.

What does %% do in batch file?

Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.

Can you run two batch files at the same time?

Note: You cannot run two batch files at the same time. Instead of typing the command at the command prompt, you may find it more expedient to enter the command line into a batch file (a text file with the file extension .


2 Answers

Use call:

Calls one batch program from another.

CALL [drive:][path]filename [batch-parameters]

  batch-parameters   Specifies any command-line information required by the
                     batch program.

If you invoke other batch files without call then control is passed to them but not back again (which is what call changes).

like image 83
Joey Avatar answered Oct 21 '22 21:10

Joey


use start command to launch it in a new window.

start /wait getftp.bat

like image 22
adarshr Avatar answered Oct 21 '22 19:10

adarshr