how to run cmd from batch file and go to folder within parent folder

15,214

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
Share:
15,214
agarwal_achhnera
Author by

agarwal_achhnera

Updated on June 14, 2022

Comments

  • agarwal_achhnera
    agarwal_achhnera almost 2 years

    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