Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Execute .bat file from applet?

Posted on 1997-04-04
1
Medium Priority
?
552 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
JWBito earned 150 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 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…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

722 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