I found some code a few days ago that reads the executable path of every process but returns an error when trying to get certain processes. I didn't make all of this code :
Expand|Select|Wrap|Line Numbers
- Dim example as integer
- Dim file2 As String
- For Each p As Process In Process.GetProcesses
- Try
- file2 = p.Modules(0).FileName
- Catch ex2 As System.ComponentModel.Win32Exception
- file2 = "n/a"
- End Try
- If file2 = "C:\example.exe" Then
- example += 1
- End If
- Next
I don't want just the filename, anyone can bypass that and if it has the same name as "explorer.exe" for example, that could cause a problem.