1

I'm trying to call second.bat file from first.bat file(Mean to say first.bat is main file which is calling second.bat and second.bat is called one).

first.bat

echo Going to call second batch file

call second.bat

echo End of first batch file.

exit 0

second.bat

@echo off

setLocal EnableDelayedExpansion

cmd /c start /b jre\bin\java -Djava.library.path=nativelib -classpath SampleTest.jar com.test.SampleTest argument1

Here the issue is when I called the second.bat from first batch file , the second.bat file is not giving control back to the first.bat file. Its just hanging.

I'm calling one Java process from second.bat file , after successful launching of that process the control should be go back to the first.bat and finish the rest of the activities of first.bat.

Here the control is not coming back.

Can anyone please help me that how I can achieve this scenario.

Thanks In Advance.

3
  • You should show us the contents of second.bat. Commented Apr 28, 2014 at 9:11
  • @echo off setLocal EnableDelayedExpansion cmd /c start /b jre\bin\java -Djava.library.path=nativelib -classpath SampleTest.jar com.test.SampleTest argument1 Commented Apr 28, 2014 at 9:15
  • Please update your question instead of putting it a comment. StackOverFlow comments don't keep newlines. Commented Apr 28, 2014 at 9:21

1 Answer 1

2

I am going to hazard a guess that your Second.bat includes a line that looks like this:

  java MyJavaProgram

If that is the case, your second Second.bat will not return until the java process has exited. If you wanted to start the process before it exits, you need to start it in a new cmd.exe:

  start "" /b "java MyJavaProgram"

Based on the OP's update, try this:

start "" /b jre\bin\java -Djava.library.path=nativelib -classpath SampleTest.jar com.test.SampleTest argument1
Sign up to request clarification or add additional context in comments.

5 Comments

Iam using the same only like cmd /c start /b jre\bin\java -Djava.library.path=nativelib -classpath SampleTest.jar com.test.SampleTest argument1
@Honey, Did you try stripping off the cmd /c and putting the argument to start inside double quotes?
Here arguement is a variable and cannot put it into a double quotes.
I have tried in your way, still no use.Any more suggestions please.
There are added title quotes in the start command, which are required when a quoted term is used in the command (and can always be added). Try it again. Reply with the error message if there is one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.