You can prevent you Computer USB port from hardware without detecting it. you don’t need any software to lock the USB port. if you are the windows user its very simple.
Step 1: Go to “My Computer” and Right Click Then “Properties”
Step 2: Go to “Device Manager”
Step 3: Find and Expand “Universal Serial Bus Controllers”
Choose the port which you want to lock (be aware and choose open usb port otherwise connected device will be disconnected) right click and select disable
Step 5: Now the USB Root Hub Disabled
Step 6: Enable USB Port When You Want.
Now check the particular USB port with pendrive or hardware you will not get device detected message
If you want to enable the USB port, then do right click on the particular USB root hub and click enable.