tags:

views:

25

answers:

2

I'm using a VB.net process to shell another exe process (which will wait until completion before processing is continued in the main app); however, I need to know if there is an error in the shelled exe process before continuing in the main app. Is there a way to do this?

A: 

Might take a look here and see if this is what you needed http://www.devx.com/dotnet/Article/7914/0/page/2

It really depends on what you're running and what you're looking to get out of it. If it is an application that you wrote then you just need to have a way to send information back. Look for an error in eventviewer? Fileoutput? MSMQ? Lots of different ways that I can think of, but really depends on what exactly you want to do, and what level of control you have over what you're running.

If it is something completely out of your control and it pops up an error message then you may be stuck. You could monitor the process itself and see what windows it has active, etc... but that may be a bit more work than what you're actually asking for.

BTT
+2  A: 

If you're using a System.Diagnostics.Process to start the process:

Dim myProcess As Process = Process.Start("C:\\Path\\To\\Exe.exe")

Do

    'Allow Process to Finish '
    myProcess.Refresh()

Loop While Not myProcess.WaitForExit(1000)

Dim exitCode As int = myProcess.ExitCode

I believe the ExitCode should be 0 if everything was successful, or another return value if there was an error.

Justin Niessner
Yes. It is in the MSDN docs for Shell: http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.interaction.shell.aspx
Hans Passant
That worked great! Thanks for the help.