views:

4064

answers:

3

The company I work for makes hardware that communicates to the computer though a serial port. Third party companies write software that communicates with our hardware.

There are times when I need to diagnose our hardware. However, a third party software app connects to the serial port when Windows starts up, blocking any other connection. I don't know the name of this application/service and it's not always the same one.

Is there any way to either:

  • Find the name/pid of the app/service that is currently using a given serial port or
  • Steal the serial port connection from another app.

vb.net preferably, but I'll take a language agnostic answer as well.

+2  A: 

Sysinternals has a slew of utilities I find very useful and educational for tracking down what processes are doing to the system.

They have a utility that does exactly what you need called Portmon, and give some information on how it works near the bottom of the page. That info and a few well-asked questions will probably give you everything you need to implement it yourself if the utility isn't enough.

Adam Davis
A: 

@Rob Walker
That works well enough. Ideally I'd like something that your standard "grandma" user could run, but this is still worlds beyond what I was doing (Closing everything item by item, in most cases over the phone, then returning to hyperterminal to see if it worked).

@Adam
Just looked at portmon, but apparently portmon has to nab the serial port first (before any other apps get to it). Other applications then connect to portmon's virtual port. It won't tell you if a program is already using a serial port (it gives a "This port is busy" error message).

Grant
+4  A: 

You can use the process explorer tool also from SysInternals to search for open handles. In this case you would want to search for 'Serial' since it uses device names that may not map to com port numbers. (e.g. COM1 is \Device\Serial0 on my system).

If you want to take control of the serial port from another app I think you would need co-operation of the driver.

Rob Walker