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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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()
            Console.WriteLine("Process Failed")
        End Try
    End Sub
End Module

Open in new window

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).


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


   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.

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.