Results 1 to 16 of 16

Thread: Reboot

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Reboot

    Hi guys,

    Instead of using a .cmd file and programming to launch after xx processes, can I launch my form (Reboot form) after all other processes........

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Reboot

    And again, in English ..... ?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Reboot

    What? it's in full english and clear...

    @dun, u no my project from b4, so all the installer files, i'm starting in the app as a process, now can I launch my reboot form after all processes finish?

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Reboot

    Hmm, it's English but not as we know it, Jim! Anyway, to track processes ....

    vb.net Code:
    1. Dim WithEvents p As New Process With {.EnableRaisingEvents = True}
    2.  
    3.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    4.         AddHandler p.Exited, AddressOf ProcessExit
    5.         p.StartInfo = New ProcessStartInfo("notepad")
    6.         p.Start()
    7.     End Sub
    8.  
    9.     Private Sub ProcessExit(sender As Object, e As System.EventArgs)
    10.         MsgBox("Notepad gone bye-bye")
    11.     End Sub
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Reboot

    I no how to start, stop and track, i'm launching 30+ proceess 1 after other, so how to showw reboot form after all finished.......?

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Reboot

    Using the Exited events. Link all the processes to a single handler and use the sender variable to identify which have exited. Once all the processes you started are accounted for then open the form.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Reboot

    Yay u understood, now can u help me do that, like I said i've no clue......

  8. #8
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,376

    Re: Reboot

    Quote Originally Posted by chris-2k View Post
    Yay u understood, now can u help me do that, like I said i've no clue......
    It looks like Dunfiddlin provided an example of the Exited event: AddHandler p.Exited, AddressOf ProcessExit. To use the sender variable, use DirectCast or CType.
    Last edited by dday9; May 7th, 2013 at 02:55 PM. Reason: Added MSDN links
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Reboot

    I do apologize m8's but i need to check if all process exited/??

    Really i have no clue......

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Reboot

    I'm making the following assumption:

    U no how 2 tr4nsl8 2 VB
    Code:
    sub S()
      4 x = 0 2 apps.length -1
        d1m p = new proc with {.EnableRaisingEvents = tru}
        +Handler p.Xited, +dressOf Yo
        p.St4rt1nfo = new ProcessStartInfo(apps(x))
        p.Start
      nXt
    end sub 
    
    sub Yo()
      static c as int =0
      c+=1
      if c = apps.length then
        doIt
      end if
    end sub
    Gr8, give r8ings m8.
    Last edited by Joacim Andersson; May 7th, 2013 at 03:31 PM.

  11. #11
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Reboot

    vb.net Code:
    1. Public Class Form1
    2.  
    3.     ' We'll assume you have all the filepaths in a listbox
    4.     ' it would work the same for any other collection type
    5.  
    6.     Dim pCount As Integer
    7.     Dim p() As Process
    8.  
    9.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'launch
    10.  
    11.         pCount = ListBox1.Items.Count
    12.         ReDim p(pCount - 1)
    13.  
    14.         For i = 0 To pCount - 1
    15.             p(i) = New Process With {.EnableRaisingEvents = True}
    16.             AddHandler p(i).Exited, AddressOf ProcessExit
    17.             p(i).StartInfo.FileName = ListBox1.Items(i).ToString
    18.             p(i).Start()
    19.         Next
    20.  
    21.     End Sub
    22.  
    23.     Private Sub ProcessExit(sender As Object, e As System.EventArgs)
    24.  
    25.         pCount -= 1
    26.         If pCount = 0 Then
    27.             MsgBox("All Done")
    28.         End If
    29.  
    30.     End Sub
    31.  
    32. End Class
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Reboot

    haha sorry don't understand Joacim lol

  13. #13
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,376

    Re: Reboot

    Quote Originally Posted by Joacim Andersson View Post
    I'm making the following assumption:

    U no how 2 tr4nsl8 2 VB
    Code:
    sub S()
      4 x = 0 2 apps.length -1
        d1m p = new proc with {.EnableRaisingEvents = tru}
        +Handler p.Xited, +dressOf Yo
        p.St4rt1nfo = new ProcessStartInfo(apps(x))
        p.Start
      nXt
    end sub 
    
    sub Yo()
      static c as int =0
      c+=1
      if c = apps.length then
        doIt
      end if
    end sub
    Gr8, give r8ings m8.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Reboot

    @dun, here's my install form, as u see no listbox, reads straight from .ini:
    Code:
    Public Class InstallPrograms
        Dim file_name As String = "./Start/InstallCFG.ini"
        Dim stream_reader As New IO.StreamReader(file_name)
        Dim line As String
        Dim ReadResult() As String
    
        Sub Form1_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyUp
            If e.KeyData = Keys.F1 Then
                Editor.ShowDialog()
            End If
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            line = stream_reader.ReadLine() 'Read InstallCFG.ini File
    
            Do While Not (line Is Nothing)
                ReadResult = line.Split(":") 'Split line at :
    
                If (ReadResult(0).ToLower() = "prog name") Then
                    Label3.Text = "Installing " + ReadResult(1)
                End If
    
                If (ReadResult(0).ToLower() = "installer file") Then
                    PictureBox1.ImageLocation = ".\images\System-Working.gif"
                    Label3.Refresh()
                    Label5.Refresh()
                    Dim info As New System.Diagnostics.ProcessStartInfo
                    info.FileName = ReadResult(1) 'Open the application
    
                        Dim myProcess As New System.Diagnostics.Process
                        myProcess.StartInfo = info
                        myProcess.Start() 'Start the process
                        myProcess.WaitForExit() 'Wait until the process started is finished
                        myProcess.Close() 'Release the resources
                        Label5.Text = "Install Complete..."
                        Label5.Refresh()
                        System.Threading.Thread.Sleep(750)
                        Label5.Text = ""
                        Label5.Refresh()
    
    
                    Else
                        MessageBox.Show("Something is wrong! File = " & ReadResult(1))
                End If
    
                line = stream_reader.ReadLine() 'Move on to the next line.
            Loop
            stream_reader.Close()
        End Sub
    End Class
    Don't worry, the stuff we/you did yesterday is in select app form

  15. #15
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: Reboot

    Quote Originally Posted by Joacim Andersson View Post
    I'm making the following assumption:

    U no how 2 tr4nsl8 2 VB
    Code:
    sub S()
      4 x = 0 2 apps.length -1
        d1m p = new proc with {.EnableRaisingEvents = tru}
        +Handler p.Xited, +dressOf Yo
        p.St4rt1nfo = new ProcessStartInfo(apps(x))
        p.Start
      nXt
    end sub 
    
    sub Yo()
      static c as int =0
      c+=1
      if c = apps.length then
        doIt
      end if
    end sub
    Gr8, give r8ings m8.
    visu4l b4sik?
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Reboot

    Anyone can help me sort it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width