Solved

Modify VB.NET code to launch and monitor process and exit code

Posted on 2011-09-16
1
295 Views
Last Modified: 2012-05-12
I would greatly appreciate some assistance modifying the code below so that my program will launch the process shown on line # 8, while keeping the path variables and all related material intact, and then monitor the process for its exit code.

Once the exit code is transmitted, the exit code should be stored in a variable and then the contents of that variable (which is the exit code) should be written to a process status log file located at ("\%SystemDrive%\Documents and Settings\All Users\Documents\ProcessStatusLog.txt")

Ideally, if someone could re-work/tweak/add-to the code below, and paste the revised code in their answer, I would greatly appreciate it.

Public Class MyProgram
    Dim MyPathVariable As String

    Private Sub MyApp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MyPathVariable = My.Application.Info.DirectoryPath.ToString()

        Try
            Shell(MyPathVariable & "\setup.exe /s /f1" & MyPathVariable & "\setup.iss")

          'Application.Exit()
        Catch ex As Exception
            Dim file As New System.IO.StreamWriter("\%SystemDrive%\Documents and Settings\All Users\Documents\MyProgramErrorLog.txt")
            file.WriteLine(ex.ToString)
            file.Close()
        End Try
    End Sub
End Class

Open in new window


0
Comment
Question by:ACECORP
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 36552086
See my post in your other question:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_27312603.html#36551643

The Exited() event also gives you the ExitCode of the Process:
Private Sub P_Exited(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim P As Process = CType(sender, Process)
        ' ... do something with "P.ExitCode" ...
        Debug.Print(P.ExitCode)
        Application.Exit()
    End Sub

Open in new window

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question