Can a PC serial port be put on track programmatically?

A PC with Windows 7 contains a native serial port (i.e. not USB), which is connected to a transmitting external instrument.
Data is streaming continuously, regardless if the PC is powered on, or not.
There is no handshaking and the PC is only hooked up for receiving.

Now, powering up the PC means that data is streaming in before the PC has fully booted and the operating system has initialized the port.
This causes issues. When the Xojo-program eventually starts, a MsgBox shows ‘The serial port could not be opened’.

So, the current workaround for the customer is to disconnect the transmitting instrument during boot.
But is there any method to instead programmatically recover the serial port to working condition after boot?

Thanks in advance.

its better to test this behavior with your own pc & xojo app (maybe in vm).
i would look if the com port is same at windows after pc boot & recognised.
(device manager)

The serial port could not be opened

you need to know why

That take me back a bit.

If it is the same problem I ran into. When a device is transmitting on the serial port when Windows boots, Windows may incorrectly assume the device is a serial mouse. Plug n Pray is triggered to install the driver and the driver subsequently holds the port open.

Disabling the serial mouse service in the registry should sort it out.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sermouse] “Start”=dword:00000004

Thank you all,

That looks interesting.
Btw, somewhere else I got the advise to reset via IOCTL_SERIAL_PURGE.

When I can lay my hand on that very PC again I will test,
at least the ‘mouse trick’, which seems straight forward.