Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:54:31+00:00 2026-05-30T02:54:31+00:00

I create a .bat file in my java application(Runtime),then run .bat file and use

  • 0

I create a .bat file in my java application(Runtime),then run .bat file and use of waitFor() method to waiting for terminate .bat file,but process no wait for terminate .bat file.

Code:

  public boolean restoreDepot() {
   try {
     InputStreamReader _input = new  
      InputStreamReader(getClass().getResourceAsStream("/Depot/DBMakaseb.sql"));
     BufferedReader _in = new BufferedReader(_input);

     String _currentpath = (new File(".")).getCanonicalPath() + File.separator + "DBDepot.sql";
     BufferedWriter _out = new BufferedWriter(new FileWriter(_currentpath));

     while (_in.ready()) {
        _out.write(_in.readLine());
        _out.newLine();
     }

     _in.close();
     _out.close();


     String _comCur = "set cur=%cd%";
     String _comCD = "Cd /d %PROGRAMFILES%\\MySQL\\MySQL Server 5.5\\bin";
     String _comando = "mysql -u root -pm117988m < %cur%" + "\\DBDepot.sql";
     String _comExit = "exit";
     BufferedWriter _out1 = new BufferedWriter(new FileWriter("restore.bat"));
     _out1.write(_comCur);
     _out1.newLine();
     _out1.write(_comCD);
     _out1.newLine();
     _out1.write(_comando);
     _out1.newLine();
     _out1.write(_comExit);
     _out1.close();


     Process _p = Runtime.getRuntime().exec("cmd /C start restore.bat");

     int _res = _p.waitFor();


     while (!(((new File(_currentpath)).delete()) && ((new File((new File(".")).getCanonicalPath() + File.separator + "restore.bat")).delete()))) {
     }

     if (_res != 0) {
        return false;
     }

     return true;
  } catch (Exception err) {
     System.out.println(err);
  }

  return false;

}

Please Help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:54:33+00:00Added an answer on May 30, 2026 at 2:54 am

    It has to do with your usage of start.

    Remove start, only to leave

    Process _p = Runtime.getRuntime().exec("cmd /C restore.bat");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a BAT file to run an application through telnet, but
I need to create a .bat file to run java program. I have a
I want to create .bat application that read into text file, find / and
Hi I have created a java application and created a jar file. Then I
I wanted to run a .cmd file from Java. I have something which works
How to create a .BAT file to download file or folder from FTP server?
How to create a .BAT file to download and unpack a zip file from
I'm wanting to create a process from a different location to where my application
Imagine I create a .bat file in the following directory: \trunk\Samples\PubSub\ @ECHO OFF ECHO
I trying to create a bat file using csharp which contains some commands. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.