I know this is off topic but I haven't been able to get help anywhere else.
I would like my program to execute (via Runtime.exec or some other mechanism) a
command that is typed into a TextField. Anything that might be
executed from a System prompt should also work from my program. Below is
the program code. It successfully executes instructions such as
"C:\WINNT\Notepad.exe"
and
"Notepad"
but not
"C:WINNT\SYSTEM32\cmd.exe C:\my.bat"
or even
"C:WINNT\SYSTEM32\cmd.exe C:\WINNT\Notepad.exe".
No exceptions are generated.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Executor extends Frame{
public static void main( String[] arg ){
new Executor();
}
public Executor(){
setLayout( new GridLayout( 0, 1 ) );
final TextField field = new TextField();
add( field );
Button b = new Button( "Execute" );
b.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent e ){
try{
Runtime.getRuntime().exec( field.getText() );
}catch( IOException ex ){
ex.printStackTrace();
}
}
});
add( b );
pack();
setVisible( true );
}
}
On Sun, 14 Mar 1999 15:55:21 -0700, Michael Allen Latta <[EMAIL PROTECTED]> wrote:
>BAT files are not directly executable. You need to use the cmd.exe program
>with the bat file as a command line input to execute bat files using the
>exec function.
>
>Michael Allen Latta
>Sun Certified Java Programmer
>Ohana Technologies Corporation
>http://www.ohanatech.com
>[EMAIL PROTECTED]
>Voice: 303-661-9837
>Fax: 303-661-0958
>
>
>------------------------------------------------------------
>To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
>Java 3D Home Page: http://java.sun.com/products/java-media/3D/
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".