I have a program (environment is Windows 7 Enterprise 32bit) that scans available serial ports to detect a specific device.
But on many machines a printer driver is configured on one of the serial port (this does not means that there is actually a printer connected to that port). In this case, my scan program can't open that port to search the device.
On Windows XP, stopping the spooler before starting the scan was enough to unlock serial ports allocated by the printer drivers. On Windows 7, this is not working anymore. If I have a printer configured on COMx and I stop the spooler, COMx can't be opened.
I've checked process locks with ProcExp: ports results allocated by spoolsv.exe process when spooler is running, and results NOT allocated by anyone when the spooler is stopped.
Any idea about how to momentarily unlock ports allocated by printers?
A workaround I found is to change port of every serial printer to FILE: before the scan and back to the COMx when the scan finished, but I wonder if there is a simpler solution.