launching command prompt window - Windows NT

This is a discussion on launching command prompt window - Windows NT ; I don't follow this newsgroup. Please point me to an FAQ list for this list if the Q/A is there since this is probably asked often. I would like to launch a new command prompt window from my Java GUI ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: launching command prompt window

  1. launching command prompt window


    I don't follow this newsgroup. Please point me to an FAQ list for this
    list if the Q/A is there since this is probably asked often.

    I would like to launch a new command prompt window from my Java GUI and then
    have it execute a command (I guess via a batch file). I also need to do this
    on a Linux machine, dependent the OS in use; I can ask this elsewhere since
    it is probably not appropriate here, but in case someone knows how :-)

    Thank you for taking time.

    - Andrew M. Neiderer

  2. Re: launching command prompt window


    "Andrew Neiderer " wrote in message
    news:I7DGn1.KIp@arl.army.mil...
    >
    > I don't follow this newsgroup. Please point me to an FAQ list for this
    > list if the Q/A is there since this is probably asked often.
    >
    > I would like to launch a new command prompt window from my Java GUI and

    then
    > have it execute a command (I guess via a batch file). I also need to do

    this
    > on a Linux machine, dependent the OS in use; I can ask this elsewhere

    since
    > it is probably not appropriate here, but in case someone knows how :-)
    >
    > Thank you for taking time.
    >
    > - Andrew M. Neiderer


    - To start a Command Prompt: cmd.exe
    - To start a Command Prompt and execute a command: cmd.exe /c
    c:\tools\SomeCommand.exe
    - To start a Command Prompt, execute a command and stay resident: cmd.exe /k
    c:\tools\SomeCommand.exe

    The above options are nicely visible when you type cmd /?
    at the Command Prompt.



  3. Re: launching command prompt window

    "Pegasus (MVP)" wrote:
    >
    > "Andrew Neiderer " wrote
    > >
    > > [...]
    > >
    > > I would like to launch a new command prompt window from my Java GUI and

    > then
    > > have it execute a command (I guess via a batch file). I also need to do

    > this
    > > on a Linux machine, dependent the OS in use; I can ask this elsewhere

    > since
    > > it is probably not appropriate here, but in case someone knows how :-)
    > > [...]

    >
    > - To start a Command Prompt: cmd.exe
    > - To start a Command Prompt and execute a command: cmd.exe /c
    > c:\tools\SomeCommand.exe
    > - To start a Command Prompt, execute a command and stay resident: cmd.exe /k
    > c:\tools\SomeCommand.exe
    >
    > The above options are nicely visible when you type cmd /?
    > at the Command Prompt.


    It's OT here, :-), but

    if this is really all you want to do it's easily done by the Class
    Runtime, e.g. (for WinNT):

    public class Fun {
    public static void main (String[] args) throws java.io.IOException {
    Runtime.getRuntime().exec("cmd /cdir > c:\\out.txt");
    }
    }

    This tiny program will start a new process sending the String argument
    to the parent of the VM (it's really quick'n'dirty, ;-) )
    See Javadocs for more details.

    cmd /c will execute the following "String" "dir > c:\out.txt" (backslash
    has to be masked) and then quit (a must if you really want to it this
    way - otherwise your new "cmd"-process will never end).

    This will print the current working directory to a file "out.txt" on c:\
    (of course for NT4+ only).

    Replace the String by whatever you want to send to the (platform
    dependend) shell of your VM.

    Stephan

+ Reply to Thread