Results 1 to 6 of 6

Thread: [RESOLVED] Failed to detect process

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Resolved [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.

  2. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    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.

  4. #4
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Failed to detect process

    Quote Originally Posted by VB.NET Developer View Post
    @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."

  5. #5
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: Failed to detect process

    Quote Originally Posted by VB.NET Developer View Post
    @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.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    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
  •  



Click Here to Expand Forum to Full Width