I am trying to monitor a process that the user has chosen. What I am doing is trying to get the filename from the process name so when the process is not found it can launch it again. Now I don't understand my problem. I am getting the error here: Dim s As String = ProcessArray(0).MainModule.FileName
.
The thing I do not understand is that it is returning the filename fine. Can anyone help me pinpoint the issue?
Dim ProcessArray As Process()
ProcessArray = Process.GetProcessesByName(procName)
Dim s As String = ProcessArray(0).MainModule.FileName
Dim f As Process
Dim p As Process() = Process.GetProcessesByName(procName)
For Each f In p
If p.Length > 0 Then
For i As Integer = 0 To p.Length - 1
ProcessID = (p(i).Id)
Next
Else
ProcessID = 0
End If
If ProcessID = 0 Then
BotRunning = False
Process.Start(s)
watchdogbool = True
RunBot(watchdogList, ItemClicked.Text, -1)
End If
Next