Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Calling an .exe, is it possible?

Options
  • 08-07-2002 4:41pm
    #1
    Closed Accounts Posts: 1,719 ✭✭✭


    ok i need to write a prog that can call an exe.
    now all i need to do is call the exe,and wait for it to execute,then call another exe.. when the second exe is called i want the application to then exit.
    is this possible at all?
    preffered languages would be java(have a good grasp of it,although i think it's not possible to do it in a java enviroment)
    or C++(which i have only been learning for a few days now :( )
    so any suggestions?


Comments

  • Closed Accounts Posts: 1,719 ✭✭✭Ruaidhri


    hmmm,yes it's a start,but the two exe's cant be executed at the same(they are 2 setup's,one has to installed first,then the other one)
    this wont let me do this(arghh!)
    even assembly will be considered :)

    any suggestions?

    [edit]
    wait i think i'm getting the idea. new you can setup an object returned from "process" which controlls the program.so all i need is a loop to wait for some charistic of this object to change,then break the loop and start the next exe.
    hmmm now wtf is process?..
    /me looks at java.sun.com
    BTW thanks Verb :)
    [/edit]


  • Closed Accounts Posts: 19 snake_eyes


    Runtime.getRuntime().exec("whatever").waitFor()


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Make a batch file called "Sample.bat" like so.
    @echo off
    echo starting first program.
    start /w runme1st.exe
    
    echo 1st program finished, starting second program.
    start /w runme2nd.exe
    
    echo Both programs have finished. 
    


  • Closed Accounts Posts: 1,719 ✭✭✭Ruaidhri


    thenks

    just got a solution myself :D
    import java.lang.Runtime;
    public class Test
    {
    public static void main(String argv[])
    {
    Process p;
    Runtime r = Runtime.getRuntime();
    try {
    p = r.exec("notepad.exe");
    p.waitFor();
    }

    }
    }

    thanks for the help :)


  • Advertisement
  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    If its for Windows, you could also check out the api's CreateProcess/WinExec/ShellExecuteEx.


Advertisement