2

I have to create a batch file as below

1) It will run cmd
2) then withing that command prompt goes back to parent folder may be with cd..
3) then go to folder jar may with cd jar
4) run command java -jar TASKApi.jar

and this command prompt should remain open

currently I am using below code

start cmd.exe /k cd..
cd jar
java -jar TASKApi.jar 

But only first line works other two line does not
Please tell me how can I do this

4
  • 1
    You dont have to run cmd.exe to run java file. You can remove the first line and save the file at .bat and run it directly. because batch files run only on command prompt. Commented Jan 10, 2014 at 7:40
  • 1
    @CodeXerox And what should i do to remain command prompt so that user can further enter commands on that command prompt Commented Jan 10, 2014 at 7:48
  • Are you trying to run this at the prompt or from a shortcut? Commented Jan 10, 2014 at 8:06
  • this batch file run from start menu Commented Jan 10, 2014 at 8:10

1 Answer 1

7

Edited after a comment below:

:: two.bat
@echo off
cd /d "c:\folder\jar"
java -jar "TASKApi.jar" 

To keep the console window open for further input, launch the batch file above from another batch file.

:: one.bat
@echo off
cmd /k call two.bat
Sign up to request clarification or add additional context in comments.

3 Comments

pause show message press any key to continue..., I just want to remain the command prompt and user can further enter command on this, what should I do
See if the technique above suits you.
is this not possible with only one batch file

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.