There is no universal way of telling when a computer is docked, unfortunately. Many docks just appear as a USB hub with a stack of devices attached and duplicating some IO ports, some do actually behave as a 'dock' which would allow what you've tried already.
Statistics: Posted by cobian — 03 Apr 2022, 22:53