Solved

Execute .bat file from applet?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 61
Windows 10 IE Certificate Issue 10 51
jsp insert to database example 2 43
mysql jsp example issue 32 48
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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:

792 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