I want to have a code that when the users internet connection disabled, shut down the chrome.exe
as you can see below this.
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim ip = "www.google.com"
Dim timeout = 1000
Dim sw = New Stopwatch()
myProcesses = Process.GetProcessesByName("chrome")
Try
Dim ping As Long = -1
sw.Start()
If My.Computer.Network.Ping(ip, timeout) Then
sw.Stop()
ping = sw.ElapsedMilliseconds
For Each myProcess In myProcesses
If myProcess IsNot Nothing Then
myProcess.Kill()
MessageBox.Show("Internet down")
Me.Close()
End If
Next
End If
If ping < 500 Then
Else
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
End Sub
Can you help me with this, where is the problem with it ? Also I enabled the Timer1 so I think it should work properly.
Thanks for help to everyone, sorry to take your time for this type of small problems.