Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

13 Experts available now in Live!

Get 1:1 Help Now