How to seize a serial port occupied by an unknown process?

  serial-port, windows

On our public computer, it often occurs that some other users forget to free the serial port before leaving. Then the next user will have to physically unplug the COM device and plug it back each time it is occupied by an unknown process. Is it possible to write some code to talk to the OS to seize the serial port, from the unknown occupying process to the currently running foreground app that is going to serve the user?

Source: Windows Questions