How to determine if a Process started/was successful

I am writing a Visual basic 2013 console application to register COM dlls. The code I will be using is:
Dim process As New System.Diagnostics.Process()
process.Start("C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Regasm.exe", """C:\OtherDLL\ShowNotes\ShowNotesVS.dll"" /tlb:""C:\OtherDLL\ShowNotes\ShowNotesVS.tlb"" /codebase")

Open in new window


Is there any way to determine if this process was successful?

Thanks,
pat
mpdillonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
try catch block works
mports System.Diagnostics
Module Module1
    Sub Main()
        Dim process As New Process()
      Try
            Process.Start("xnotepad.exe")
        Catch
            Console.WriteLine("Process Failed")
        End Try
        Console.ReadLine()
    End Sub
End Module

Open in new window

0
Jacques Bourgeois (James Burger)PresidentCommented:
As I told you in another post, if you want to do a little more, give a look at the documentation for the Process class. In the page for the Start method that you used, they tell you that if the process started successfully, you are returned a Process object, otherwise, you get a null (Nothing in VB).

So:

If process.Start("C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Regasm.exe", """C:\OtherDLL\ShowNotes\ShowNotesVS.dll"" /tlb:""C:\OtherDLL\ShowNotes\ShowNotesVS.tlb"" /codebase") = Nothing Then

    MessageBox.Show ("Sorry, something wrong")

Else

   MessageBox.Show("Look at that start! Wow!")

End If

Open in new window


But David suggestion will trap errors if there are some, such as a missing file, and it is worth keeping the call between a Try...Catch, something that you should do anyway by default everytime that you deal with stuff such as files, that might be missing or in the wrong place when you run your code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.