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

Recommended Answers

All 6 Replies

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

@Reverend Jim

Thank You, Works as expected

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")

@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

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.

Check out the StartInfo property of the process class. It has the WindowStyle property that allows you to hide or minimize the window. It accepts any of the ProcessWindowStyle enumeration values.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.