You can not. A barcode scanner is a keyboard (sorts). It enters text characters just like a keyboard.
I believe that one option would be to disable the physical keyboard. And by not allowing this, you can "try" to block input based on the hardware serial number. But the problem is that a) that it does not scale, and b) if your scanner ever dies, you need a monkey with your software.
Also remember, barcodes are simply linear representations of human-readable characters. This way, you can enter tiny numbers under the barcode manually if your scanner cannot read them.
I would step back and tell the boss that a bad idea (depending on the context of the request, of course).
source share