How do I pass return codes on exit?

I would like to call a program using Call Shell(), wait for it to finish, then (if possible), collect the data it returns (as if it were a function). My question is, how do I make a program that sends data back when it exits, and how do I make another program that calls this program, then gets the data



Answer this question

How do I pass return codes on exit?

  • Jayanth

    Also if you want to talk to a console application, a full example is there in your VB express help:

    ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/cpref6/html/M_System_Diagnostics_Process_BeginOutputReadLine.htm

    or search "Process.BeginOutputReadLine Method" in the help



  • nikolami

    I'm just a newbee. So I am throwing this out to the experts.

    If he is writing/controlling both programs could he not possibly:

    Put data in the clipboard in one program and read it in the other program

    Put data in the registry in one program and read it in the other program

    ........ Me.exit.now :)



  • Rudy W.

    Environment.ExitCode = MyExitStatus

  • TomWolle

    W00T I hadn't even thought about that! I'd rather leave the registry and clipboard alone, but thanks for the good idea anyway!


  • hello one

    This could work when you write console mode programs. Their return value (the integer value you assign to the main() function's return value) is accessible in .BAT and .CMD files with the "if errorlevel==" statement.

    The Shell() function doesn't give you that return value. Nor is it available from running Windows GUI programs. Nor is it available when you use the .NET Process class to start a program.

    A simple integer return value probably doesn't fulfill your needs. Consider using files to pass data between programs. Or writing a monolithic program that takes care of all the functionality you need...



  • syncter

  • AG2004

    Thanks for your help everyone!


  • How do I pass return codes on exit?