Link to home
Start Free TrialLog in
Avatar of bostonste
bostonste

asked on

Problem with process.getprocessbyname

I have this sub to check if somthing is running

  Sub OnCreated(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
        'MessageBox.Show("On Created")
        Dim programName As String = "notepad"
        Dim p() As process = process.GetProcessesByName(programName)
        If p.Length > 0 Then
            Exit Sub
        Else
            If IO.File.Exists("C:\Program Files\Portland Software\Primopost\scanner.exe") Then
                System.Diagnostics.Process.Start("C:\Program Files\Portland Software\Primopost\scanner.exe")
            End If
        End If
    End Sub

The problem i have is that      process.GetProcessesByName(programName) is not a member of process
Can any one tell me what i need to do to sort it out
SOLUTION
Avatar of ladarling
ladarling
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wwnosal
wwnosal

Hmm This works for me:
 Dim p() As Process
    p = Process.GetProcessesByName("notepad")
Avatar of bostonste

ASKER

Here is a screen shot, it must be somthing to do with the type of sub it is in but i cant see what it is
Doc1.doc
i need to be able to see if somthing is running here, any ideas of a better way if if the get process doesnt work
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think the problem is with your declaration..
Try like this:
 Dim p() As System.Diagnostics.Process

and then assign...
Chaps
Thank you all
Its so easy when you know how isnt it :)
Type inference is a great thing... I dont know why people hesitate to use it :-)