Solved

Execute .bat file from applet?

Posted on 1997-04-04
1
537 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mapAB Challlenge 35 128
Java Jpanels and Jframe 8 28
VB Script to add site to Java Exception List 4 54
Opening PDF on button click and fill new document 2 23
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

863 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

20 Experts available now in Live!

Get 1:1 Help Now