-
Feb 14th, 2021, 10:35 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Failed to detect process
Hi,
I am facing strange behavior. I want to detect specific process (ping.exe for example), but Im still getting process not found message, though ping.exe is still running. Maybe my other issue is related with this, I dont know. I dont know what causes that. Can you help me?
Code:
Public Class ProcessDetector2
Private Sub ProcessDetector2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProcessDetectorTimer.Interval = 10000
ProcessDetectorTimer.Start()
End Sub
Private Sub ProcessDetectorTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProcessDetectorTimer.Tick
If Process.GetProcessesByName("PING.EXE").Length > 0 Then
Else
MsgBox("Process NOT found!", MsgBoxStyle.Critical)
End If
End Sub
End Class
Please dont forget to add good reputation if my advices were useful for you.
How? Under this post there is "RATE THIS POST" button. Click on it.
-
Feb 14th, 2021, 07:13 PM
#2
Re: Failed to detect process
Hi, maybe try it like this: -
Code:
Public Class ProcessDetector2
Private Sub ProcessDetector2_Load() Handles MyBase.Load
ProcessDetectorTimer.Interval = 10000
ProcessDetectorTimer.Start()
End Sub
Private Sub ProcessDetectorTimer_Tick() Handles ProcessDetectorTimer.Tick
Dim flag as Boolean
For Each P As Process In Process.GetProcesses
If P.ProcessName = "PING.EXE" Then flag = True
Next
If Not flag Then MsgBox("Process NOT found!", MsgBoxStyle.Critical)
End Sub
' You can also use flag to trigger whatever. (In this subroutine, or make flag global to use elsewhere)
End Class
Poppa
PS.
Just thought... You may not need the '.EXE', just...
Code:
If P.ProcessName = "PING" Then flag = True
Pop
Last edited by Poppa Mintin; Feb 14th, 2021 at 07:22 PM.
Reason: Added PS.
Along with the sunshine there has to be a little rain sometime.
-
Feb 15th, 2021, 12:54 PM
#3
Thread Starter
Hyperactive Member
Re: Failed to detect process
@Poppa Mintin
Thanks, but it does not work. I am still getting process not found message. I thought that something else interfere with my project and thus I created new project with code you provided, but I am still getting not found message... it does not work for any process for example notepad.exe or downloadmanager.exe or explorer.exe...
Please dont forget to add good reputation if my advices were useful for you.
How? Under this post there is "RATE THIS POST" button. Click on it.
-
Feb 15th, 2021, 01:53 PM
#4
Re: Failed to detect process
Originally Posted by VB.NET Developer
@Poppa Mintin
Thanks, but it does not work. I am still getting process not found message. I thought that something else interfere with my project and thus I created new project with code you provided, but I am still getting not found message... it does not work for any process for example notepad.exe or downloadmanager.exe or explorer.exe...
Always read the documentation:
https://docs.microsoft.com/en-us/dot...e?view=net-5.0
"The process name is a friendly name for the process, such as Outlook, that does not include the .exe extension or the path."
-
Feb 15th, 2021, 05:29 PM
#5
Re: Failed to detect process
Originally Posted by VB.NET Developer
@Poppa Mintin
Thanks, but it does not work. I am still getting process not found message. I thought that something else interfere with my project and thus I created new project with code you provided, but I am still getting not found message... it does not work for any process for example notepad.exe or downloadmanager.exe or explorer.exe...
Did you take note of the post script ?
You still talk about "notepad.exe", "downloadmanager.exe" and "explorer.exe".
What ever process you're looking for OMIT the '.EXE'.
Poppa
Along with the sunshine there has to be a little rain sometime.
-
Feb 16th, 2021, 03:45 PM
#6
Thread Starter
Hyperactive Member
Re: Failed to detect process
Thank you, OB1. Now it works as expected!
Poppa, sorry, but I didnt noticed your second code without extension...
Please dont forget to add good reputation if my advices were useful for you.
How? Under this post there is "RATE THIS POST" button. Click on it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|