0

Hi to all
long story short, i have 2 executable files

first.exe
second.exe

i want to run both with one button,
i know i can run one executable file with this code

Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
    Process.Start(My.Computer.FileSystem.CurrentDirectory & "\first.exe")
End Sub 

but how do i go about running 2 executable files with one button
and i want the second.exe file to start loading 10seconds after the first.exe loaded

im sure ill need to add a timer aswell for the 10second delay..

any help will be appreciated
thanx in advance

Edited by Ryan Nigel

4
Contributors
6
Replies
25
Views
2 Years
Discussion Span
Last Post by tinstaafl
0

You could start with a button and a timer and do

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    Process.Start(My.Computer.FileSystem.CurrentDirectory & "\first.exe")
    Timer1.Interval = 10 * 1000 'ten seconds
    Timer1.Start()

End Sub

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick

    Timer1.Stop()
    Process.Start(My.Computer.FileSystem.CurrentDirectory & "\second.exe")

End Sub
0

No need for a timer simply use the sleep function:

Process.Start(My.Computer.FileSystem.CurrentDirectory & "\first.exe")
Application.DoEvents
Threading.Thread.Sleep(10000)
Process.Start(My.Computer.FileSystem.CurrentDirectory & "\second.exe")

0

@Kb.net, thank you, your methods works aswell.

by the way, say i want to run executable first.exe in the background when i press Button1

i need to use code AppWinStyle.Hide after first.exe right so my code in line two will look something like

Process.Start(My.Computer.FileSystem.CurrentDirectory & "\first.exe", AppWinStyle.Hide)

but when using AppWinStyle.Hide
executable first.exe still doesnt open in the background.

any other ideas of how i can get executable first.exe to run in the background, prefibly i want executable first.exe to run in the Taskbar
thanx in advance guys

Edited by Ryan Nigel

0

If you use the Sleep method then your application becomes unresponsive during the sleep period. By using a timer you avoid this. You might change it slightly as

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    If Timer1.Enabled The Exit Function
    Process.Start(My.Computer.FileSystem.CurrentDirectory & "\first.exe")
    Timer1.Interval = 10 * 1000 'ten seconds
    Timer1.Start()

End Sub

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick

    Timer1.Stop()
    Process.Start(My.Computer.FileSystem.CurrentDirectory & "\second.exe")

End Sub

The extra test at the top prevents problems if the user clicks the button multiple times quickly.

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.