Solved

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

Posted on 2011-09-16
1
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

635 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