0

I'm trying to run First.bat file through java code but I'm getting error(Warning) popup that says

Windows cannot find First.bat. Make sure you typed the name correctly, and then try again.

Can anyone tell me what kind of error is it and where do I exactly place .bat file to excute?

Process batRun = Runtime.getRuntime().exec("cmd /c start First.bat");

1 Answers1

0

You are executing cmd through java and default location where cmd starts is C:\Users\Username>. Put First.bat in C:\Users\Username or provide absolute path to your First.bat like D:\\MyFolder\\First.bat

Process batRun = Runtime.getRuntime().exec("cmd /c D:\\MyFolder\\First.bat");
Sheetal Mohan Sharma
  • 2,908
  • 1
  • 23
  • 24
Vicky Thakor
  • 3,847
  • 7
  • 42
  • 67