Process.GetProcessesByName does not work as expected

G

Guest

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
 
T

Terry Olsen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top