I have a code here that will start a process and when pressed again it will kill the current process and start a new one(restart).
Private Games As New Dictionary(Of String, Process)
Private Sub GS1_Click(sender As Object, e As EventArgs) Handles GS1.Click
Dim gameservercfg As String = GameServer1.Text
Dim Key As String = gameservercfg.ToUpper
If Games.ContainsKey(Key) Then
If Not Games(Key).HasExited Then
Games(Key).Kill()
End If
Games.Remove(Key)
End If
Dim psi As New ProcessStartInfo
psi.FileName = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "GameServer.exe")
psi.WorkingDirectory = System.IO.Path.GetDirectoryName(psi.FileName)
psi.Arguments = gameservercfg
Games.Add(Key, System.Diagnostics.Process.Start(psi))
End Sub
What I want to do is, how to make it auto restart when that gameserver.exe crashes by itself?