Solved

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

Posted on 2011-09-16
1
294 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now