I couldn't come across a solution for this. I am working on a java program which creates a .bat file and executes it afterwards. the only struggle i have is, that i have to navigate to the destination the file was written to. i tried with

cmd /K cd C:/Users/user start test.bat

as well as several other versions of it. none worked. the problem is that i can't have the cmd navigate the the folder and stay there to execute the start command. any help is appreciated

1 Answer 1


You can start several programs or commands in one line by either using & or &&.

In your example that would become

cmd /K cd C:/Users/user & start test.bat

Alternatively you can also just start the batchfile with the full path and place the cd command in the batchfile itself. Example:

start c:\users\user\test.bat

and in test.bat include:

cd /d c:\users\user
:: the rest of your script
  • i tried to start the bat with start C:/Users/user/test.bat , but it terminated directly without starting. but with the & it works Apr 4, 2017 at 14:45
  • Its windows, the slashes need to go the other way, so C:\Users\user\test.bat
    – LPChip
    Apr 4, 2017 at 14:50
  • this is working now: cmd /K cd C:/Users/user & start test.bat Apr 5, 2017 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.