Process.GetProcessesByName does not work as expected

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kd

    Process.GetProcessesByName does not work as expected

    Hi All,

    Process.GetProc essesByName() is not giving the expected results. Here is a
    sample code.

    Dim TestProcess() As Process
    Try
    TestProcess= Process.GetProc essesByName("Te st.exe")
    If TestProcess.Len gth = 0 Then
    MsgBox("Not running", MsgBoxStyle.OKO nly)
    Else
    MsgBox("Running ", MsgBoxStyle.OKO nly)
    End If
    Catch ex As Exception
    MsgBox("Error!" )
    End Try

    "Not Running" is displayed, though Test.exe is running.

    Would anybody be able to figure out why?

    Thanks.
    kd


  • Terry Olsen

    #2
    Re: Process.GetProc essesByName does not work as expected

    Yes, get rid of the ".exe". and only use "Test". Not sure if
    capitalization makes a difference, but I know that the file suffix is not
    returned by the GetProcessesByN ame function.


    "kd" <kd@discussions .microsoft.com> wrote in message
    news:C449E301-54A4-4658-B597-41BF14462C8F@mi crosoft.com...[color=blue]
    > Hi All,
    >
    > Process.GetProc essesByName() is not giving the expected results. Here is a
    > sample code.
    >
    > Dim TestProcess() As Process
    > Try
    > TestProcess= Process.GetProc essesByName("Te st.exe")
    > If TestProcess.Len gth = 0 Then
    > MsgBox("Not running", MsgBoxStyle.OKO nly)
    > Else
    > MsgBox("Running ", MsgBoxStyle.OKO nly)
    > End If
    > Catch ex As Exception
    > MsgBox("Error!" )
    > End Try
    >
    > "Not Running" is displayed, though Test.exe is running.
    >
    > Would anybody be able to figure out why?
    >
    > Thanks.
    > kd
    >
    >[/color]


    Comment

    • kd

      #3
      Re: Process.GetProc essesByName does not work as expected


      Eliminating the ".exe" fixed the problem.

      Thanks Terry.
      kd.

      "Terry Olsen" wrote:
      [color=blue]
      > Yes, get rid of the ".exe". and only use "Test". Not sure if
      > capitalization makes a difference, but I know that the file suffix is not
      > returned by the GetProcessesByN ame function.
      >
      >
      > "kd" <kd@discussions .microsoft.com> wrote in message
      > news:C449E301-54A4-4658-B597-41BF14462C8F@mi crosoft.com...[color=green]
      > > Hi All,
      > >
      > > Process.GetProc essesByName() is not giving the expected results. Here is a
      > > sample code.
      > >
      > > Dim TestProcess() As Process
      > > Try
      > > TestProcess= Process.GetProc essesByName("Te st.exe")
      > > If TestProcess.Len gth = 0 Then
      > > MsgBox("Not running", MsgBoxStyle.OKO nly)
      > > Else
      > > MsgBox("Running ", MsgBoxStyle.OKO nly)
      > > End If
      > > Catch ex As Exception
      > > MsgBox("Error!" )
      > > End Try
      > >
      > > "Not Running" is displayed, though Test.exe is running.
      > >
      > > Would anybody be able to figure out why?
      > >
      > > Thanks.
      > > kd
      > >
      > >[/color]
      >
      >
      >[/color]

      Comment

      Working...