424,303 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,303 IT Pros & Developers. It's quick & easy.

Process.GetProcessesByName does not work as expected

P: n/a
kd
Hi All,

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

Dim TestProcess() As Process
Try
TestProcess= Process.GetProcessesByName("Test.exe")
If TestProcess.Length = 0 Then
MsgBox("Not running", MsgBoxStyle.OKOnly)
Else
MsgBox("Running", MsgBoxStyle.OKOnly)
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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 GetProcessesByName function.
"kd" <kd@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi All,

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

Dim TestProcess() As Process
Try
TestProcess= Process.GetProcessesByName("Test.exe")
If TestProcess.Length = 0 Then
MsgBox("Not running", MsgBoxStyle.OKOnly)
Else
MsgBox("Running", MsgBoxStyle.OKOnly)
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

Nov 21 '05 #2

P: n/a
kd

Eliminating the ".exe" fixed the problem.

Thanks Terry.
kd.

"Terry Olsen" wrote:
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 GetProcessesByName function.
"kd" <kd@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
Hi All,

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

Dim TestProcess() As Process
Try
TestProcess= Process.GetProcessesByName("Test.exe")
If TestProcess.Length = 0 Then
MsgBox("Not running", MsgBoxStyle.OKOnly)
Else
MsgBox("Running", MsgBoxStyle.OKOnly)
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


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.