Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Calling an .exe, is it possible?

  • 08-07-2002 04: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, Registered Users 2 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