Solved

Execute .bat file from applet?

Posted on 1997-04-04
1
534 Views
Last Modified: 2012-06-21
Please,

Can I execute a .bat file from Java applet?

I am trying execute a .bat file by using exec(String) method.

My code is:

param.bat
---------
c:\dos\tree.com

myFile.java
------------
        Process proceso;
        try
        {
            System.out.println("Runtime:"+Runtime.getRuntime());
                   
proceso=Runtime.getRuntime().exec("c:\\sistel\\ejemjava\\pt\\param.bat");

            System.out.println("proceso:"+proceso);
        }
        catch(IOException e)
        {
            System.out.println("bad shell");
        }

        System.out.println("The end");
    }


It do not execute the command system 'tree', but it print "The end".

It is right if I do not use a bat file, like this:

proceso=Runtime.getRuntime().exec("c:\\dos\\tree.com");

Thank you,

Arancha

0
Comment
Question by:apico
1 Comment
 
LVL 1

Accepted Solution

by:
JWBito earned 50 total points
ID: 1219418
Try
Runtime.getRuntime.exec("command.com /c c:\\sistel\\ejemjava\pt\param.bat");

On NT, command.com would be cmd.exe, instead.  

I would like to know how to get at system environment variables from java.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now