开发者

How do you determine if there is an error when using the VB.Net Shell Command?

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 开发者_C百科is an error in the shelled exe process before continuing in the main app. Is there a way to do this?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜