Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: how can i create batch file using java ...

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how can i create batch file using java ...

    how can i create batch file means a file with extention .bat .So that i can create system file....


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,307
    My Mood
    Mellow
    Thanks
    252
    Thanked 780 Times in 765 Posts

    Default Re: how can i create batch file using java ...

    Refer to the Oracle Tutorials that discuss IO (Input/Output) and writing to files.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how can i create batch file using java ...

    will u discribe it properly.....?

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,307
    My Mood
    Mellow
    Thanks
    252
    Thanked 780 Times in 765 Posts

    Default Re: how can i create batch file using java ...

    It is described properly at the topics I referred you to. Search for "java io tutorial", and the top result should be the one you need.

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Location
    Kentucky
    Posts
    3
    My Mood
    Lurking
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how can i create batch file using java ...

    If you're planning on using it for Miscellaneous reasons then it would be harder. I read somewhere that Java doesn't allow remote code to read or write files to the filesystem. If you was thinking of a way to write a java program that wrote a .bat file that created a executable on the registry it would be very difficult. If it's just on your local PC it's easier to do with the java.io.*

    PrintWriter writer = new PrintWriter("the-file-name.bat", "UTF-8");
    writer.println("start cmd.exe");
    writer.println("writes text to a file, so batch commands would go here");
    writer.close();

    I haven't tested this code btw, but it should work. I'll probably code something in a second and test it for you.
    If you have any projects you wanted to work on. Message me at my skype. shadow.byte

  6. #6
    Junior Member
    Join Date
    Dec 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how can i create batch file using java ...

    mention episode no.....

  7. #7
    Junior Member
    Join Date
    Dec 2013
    Location
    Kentucky
    Posts
    3
    My Mood
    Lurking
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how can i create batch file using java ...

    I've coded a program that will Create a .bat file, and write a start command to it to start CMD. Then I made the program use batch to open the file.

    Here is the source code

    #98C9fDJpBp - Mystic Paste

    Also, if you're trying to find a path name, and need a CurrentUser pathname, I think you can do something like this.

    C:\\Users\\%CurrentUser% or maybe It's C:\\Users\\%UserProfile%\\workspace etc, idk. You'll have to play with it.
    If you have any projects you wanted to work on. Message me at my skype. shadow.byte

Similar Threads

  1. Replies: 1
    Last Post: April 15th, 2013, 07:41 AM
  2. Error codes trying to run a batch file
    By any-mgzt in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 3rd, 2013, 07:18 AM
  3. Run a jar file inside a batch file with Windows 7 Task schduler
    By kingnachi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 15th, 2012, 10:20 AM
  4. Generating a Batch File - Static Method Error
    By Stroypet in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 17th, 2012, 12:42 PM
  5. calling a java a class connected to derby from a batch file
    By Reem in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 31st, 2010, 04:01 PM