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 6631127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:30:11+00:00 2026-05-25T22:30:11+00:00

I am creating a little program to take away some of my work by

  • 0

I am creating a little program to take away some of my work by using a GUI.
What I have right now is a little program with a button “Start” which starts a CMD-based application. What I need to do is enter a certain command in that CMD window. I want to add a button which fills out this command for me.

Is this even possible?

P.S.: CMD is Windows’s Command Prompt.

Thank you all.

  • 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-25T22:30:12+00:00Added an answer on May 25, 2026 at 10:30 pm

    This works if it is an external command:

    String command = "cmd";   //Replace with your command
    Runtime.getRuntime().exec(command);
    

    If it is an internal command then that will not work, but there is a workaround: create a batch file with the commands in it, and put a String with the path to the batch file as an argument.

    Runtime.getRuntime().exec("Temp.bat");
    

    Or you can write the batch file programmatically using this method:

    private void batch(String commands){
      try{
        String filename = "Temp.bat";
        File f = new File(filename);
        PrintWriter writer = new PrintWriter(f);
        writer.print(commands);
        writer.close();
        Runtime.getRuntime().exec(filename);
    
        long x = getTime + 3000;
        do{
          //Wait
        }while(getTime < x);
    
        f.delete();
      }catch(Exception ex){
        ex.printStackTrace();
      }
    }
    
    private long getTime(){
      SimpleDateFormat datef = new SimpleDateFormat("yyyyDDDHHmmssSSS");
      Date date = new Date();
      return Long.parseLong("" + datef.format(date));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a program where I have objects called hierarchies, which is little
I'm trying to learn python (using python3.2), and right now I'm creating a program
I have little program creating a maze. It uses lots of collections (the default
I am creating a GUI using Java. This GUI launches a program from the
I have finally gotten around to creating my first little practice program in Javascript.
I have been using C# for some time now to make a small game,
I have created this little program to calculate pi using probability and ratios. In
I'm creating a little photo sharing site for our home's intranet, and I have
I'm having little trouble creating a script working with URLs. I'm using urllib.urlopen() to
I need to create a little program that creates a backup copy of some

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.