Heike Posted February 4, 2003 Posted February 4, 2003 I am developing an EXE in VB.NET. This EXE is called by another program and that program waits until my EXE has finished (I think by using WaitForSingleObject but I'm not sure). My problem now is that the calling application wants to receive a return code. It is reading the return code by GetExitCodeProcess. But how can I send the return code? I tried Environment.Exit(42) and Environment.ExitCode = 42 and ExitProcess(42) (API) but everytime I get a 0. Are there some more possibilities to send a return code? Quote
*Experts* Nerseus Posted February 4, 2003 *Experts* Posted February 4, 2003 Using Environment.Exit(42) worked for me. I created a test project and compiled to WinTest.exe. I put the following in a text file and gave it a VBS extension (like test.vbs). Running it launches the WinTest.exe program and waits til it closes. The MsgBox does indeed show 42. Dim shell Set shell = CreateObject("WScript.Shell") MsgBox(shell.Run("wintest.exe", 1, true)) Maybe your other program isn't checking the return code, but maybe trying to receive a windows message? -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Heike Posted February 4, 2003 Author Posted February 4, 2003 Yes, my other application is checking the return code by using GetExitCodeProcess. I wrote a simple program in VB 6 that creates a process (like I expect from the other application) and then waits and after my EXE finshed gets the return code. There everything works fine. My first thought was that the other application is not able to read my return code but there is only called an API function and therefore I would think that it doesn't matter which language it uses. ??????? Quote
Recommended Posts