Question Need help with Console Process

hendrikbez

Active member
Joined
Nov 24, 2005
Messages
35
Location
South Afica
Programming Experience
1-3
I want to start osmon.exe with diffrent parameters, eg. Default, Osmon2, Osmon3, Osmon4 and Osmon5.
After Default has started it must wait 10 seconds, after osmon5 has started it must wait 15 seonds.
Then is must write the PID# to txt file.

I have the code, but when I run it, it only shows the console for 1 second, and then nothing is happening after that.

VB.NET:
Imports System.Diagnostics
Imports System.Timers
Imports System.IO
Imports System


Module Module1

    Private Osmon_Delay As New Timer(10000)
    'Private Dop_Delay As New Timer(200000)
    'Private Proxy_Delay As New Timer(15000)

    Private LaunchCounter As Integer = 1

    Private Osmon_Default As New Process
    Private Osmon_Osmon2 As New Process
    Private Osmon_Osmon3 As New Process
    Private Osmon_Osmon4 As New Process
    Private Osmon_Osmon5 As New Process

    Sub Main()
        AddHandler Osmon_Delay.Elapsed, AddressOf myElapsed
        Osmon_Delay.Start()
    End Sub

    Private Sub myElapsed(ByVal source As Object, ByVal e As ElapsedEventArgs)
        ' Static LaunchCounter As Integer = 1

        Select Case LaunchCounter
            ' ''Case 1
            ' ''    Dop_Delay.start()
            ' ''    Process.Start("e:\osb5.0\osb\bin\hrncr.exe")
            ' ''    Dop_Delay.Stop()

            Case 1
                Dim msg As String = ""
                '  This is where you save the DEFAULT name and process ID to a file 
                Osmon_Default.StartInfo.FileName = "E:\OSB5.0\OSB\BIN\osmon.exe"
                Osmon_Default.StartInfo.Arguments = "NAME=DEFAULT"
                Osmon_Default.Start()
                Console.WriteLine("DEFAULT PID = " & Osmon_Default.Id)

                msg = msg & "Osmon 1 PID#"
                msg = msg & Osmon_Default.Id
                msg = msg & "  "
                msg = msg & ControlChars.NewLine
                IO.File.AppendAllText("c:\Segment\PIDNum.txt", msg)


            Case 2
                Dim msg As String = ""
                '  This is where you save the OSMON2 name and process ID to a file  
                Osmon_Osmon2.StartInfo.FileName = "E:\OSB5.0\OSB\BIN\osmon.exe"
                Osmon_Osmon2.StartInfo.Arguments = "NAME=OSMON2"
                Osmon_Osmon2.Start()
                Console.WriteLine("OSMON2 PID = " & Osmon_Osmon2.Id)

                msg = msg & "Osmon 2 PID#"
                msg = msg & Osmon_Osmon2.Id
                msg = msg & "  "
                msg = msg & ControlChars.NewLine
                IO.File.AppendAllText("c:\Segment\PIDNum.txt", msg)

            Case 3
                Dim msg As String = ""
                '  This is where you save the OSMON3 name and process ID to a file   
                Osmon_Osmon3.StartInfo.FileName = "E:\OSB5.0\OSB\BIN\osmon.exe"
                Osmon_Osmon3.StartInfo.Arguments = "NAME=OSMON3"
                Osmon_Osmon3.Start()
                Console.WriteLine("OSMON3 PID = " & Osmon_Osmon3.Id)
                msg = msg & "Osmon 3 PID#"

                msg = msg & Osmon_Osmon3.Id
                msg = msg & "  "
                msg = msg & ControlChars.NewLine
                IO.File.AppendAllText("c:\Segment\PIDNum.txt", msg)

            Case 4
                Dim msg As String = ""
                '  This is where you save the OSMON4 name and process ID to a file   
                Osmon_Osmon4.StartInfo.FileName = "E:\OSB5.0\OSB\BIN\osmon.exe"
                Osmon_Osmon4.StartInfo.Arguments = "NAME=OSMON4"
                Osmon_Osmon4.Start()
                Console.WriteLine("OSMON4 PID = " & Osmon_Osmon4.Id)

                msg = msg & "Osmon 4 PID#"
                msg = msg & Osmon_Osmon4.Id
                msg = msg & "  "
                msg = msg & ControlChars.NewLine
                IO.File.AppendAllText("c:\Segment\PIDNum.txt", msg)

            Case 5
                Dim msg As String = ""
                '  This is where you save the OSMON5 name and process ID to a file   
                Osmon_Osmon5.StartInfo.FileName = "E:\OSB5.0\OSB\BIN\osmon.exe"
                Osmon_Osmon5.StartInfo.Arguments = "NAME=OSMON5"
                Osmon_Osmon5.Start()

                msg = msg & "Osmon 5 PID#"
                msg = msg & Osmon_Osmon5.Id
                msg = msg & "  "
                msg = msg & ControlChars.NewLine
                IO.File.AppendAllText("c:\Segment\PIDNum.txt", msg)
                Osmon_Delay.Stop()
        End Select

        LaunchCounter += 1
    End Sub
End Module
 
Back
Top