Solved

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

Posted on 2011-09-16
1
297 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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