Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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?
  • *Experts*
Posted

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

"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
Posted

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.

 

???????

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...