473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What causes this try statement to go to catch?

Sorry if the question wasn't clear, it'd be too much to type if it were.

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
  1.         Dim example as integer
  2.         Dim file2 As String
  3.         For Each p As Process In Process.GetProcesses
  4.             Try
  5.                 file2 = p.Modules(0).FileName
  6.             Catch ex2 As System.ComponentModel.Win32Exception
  7.                 file2 = "n/a"
  8.             End Try
  9.             If file2 = "C:\example.exe" Then
  10.                 example += 1
  11.             End If
  12.         Next
I need to know exactly what causes it to return "n/a" because if I were to make present to me the information from, for example, a messagebox, some processes will return "n/a" and I need it to not do that or figure out another way of grabbing the executable paths.

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.
Jul 20 '12 #1
1 1035
PsychoCoder
465 Expert Mod 256MB
In your catch statement add MessageBox.Show(ex2.Message) and that will give you the actual error. I presume it's a permission issue and this will let you know
Jul 20 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chris | last post by:
A general question here, what causes segmentation faults in malloc? Shouldn't malloc always gracefully fail? Take a look at the gdb core stack trace (from an HP-UX 11.11) Program terminated...
9
by: Steven Blair | last post by:
Hi, I need to catch exceotions on File.Delete() After checking the help, I have noticed that thgere are serevral Exceptions that can be thrown. My question is, should I catch all thes...
3
by: trint | last post by:
Here is the "catch exception" message: "The requested lookup key was not found in any active activation context" Here is where it happens: public void DoRead(IAsyncResult ar) { int BytesRead;...
3
by: Wayne Wengert | last post by:
With most web sites I build that include aspx pages, when the user loads the first aspx page there is a noticeable delay (15 - 30 sec) before it is completely loaded. What causes this. I thought it...
6
by: HLady | last post by:
I have been googling and cannot seem to find the answer I seek so I turn to the group. I have an application where I have been receiving 'Thread was being aborted' error ocasionally. In production...
0
by: Howard Kaikow | last post by:
I just did an upgrade of a VB 6 project by right clicking on the .vbp file. Project upgraded and code ran correctly. I examined the upgrade.htm file. I found a warning, so I tried clicking on...
2
by: Tav | last post by:
this seems to be a very generic error message, and the fact that i have no way of locating what causes the error is frustrating. anyway, i'll be general with my problem. i have a div on my page...
1
by: Mark | last post by:
Hi - I've an asp.net 1.1 web app, which causes JIT errors every time I run it. The error is very vague - Access is Denied - and I can't find any useful information on why it happens, or how to...
4
by: garyusenet | last post by:
Hi I'm using the following code which is finally working. Public Class Form1 Shared ActElement As Object Shared ActFields As DataSet Public Sub SetActElement() Dim objApp As New Object
1
by: John Dalberg | last post by:
What causes a server event to fire when something happens on the client? Say a user changed the gridview's page index, the server side PageIndexChanged event is fires. What makes...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.